Imports System.Data.SqlClient
Imports ADODB
....
Private Function GetTableListSQLServerDB(ByVal cnStr As String) As List(Of String)
Dim lstTables As New List(Of String)
If Not cnStr.ToLower.Contains("provider") Then
cnStr = "Provider = sqloledb;" & cnStr
End If
Try
Dim cn As New ADODB.Connection()
cn.ConnectionString = cnStr
cn.Open()
Dim rs As New ADODB.Recordset()
rs = cn.OpenSchema(SchemaEnum.adSchemaTables)
Do While Not rs.EOF
If rs.Fields("TABLE_TYPE").Value.ToString = "TABLE" Then
lstTables.Add(rs.Fields("TABLE_NAME").Value)
End If
rs.MoveNext()
Loop
rs.Close()
cn.Close()
rs = Nothing
cn = Nothing
Catch ex As Exception
MsgBox(ex.Message)
Debug.WriteLine(ex.Message)
End Try
Return lstTables
End Function
Private Function GetTableListAccess(strPathNameAccessDB As String) As List(Of String)
Dim lstTables As New List(Of String)
Try
Dim cnStr As String = "Provider = Microsoft.ACE.OLEDB.12.0; data source= " & strPathNameAccessDB
Dim cn As New ADODB.Connection()
cn.ConnectionString = cnStr
cn.Open()
Dim rs As New ADODB.Recordset()
rs = cn.OpenSchema(SchemaEnum.adSchemaTables)
Do While Not rs.EOF
If rs.Fields("TABLE_TYPE").Value.ToString = "TABLE" Then
lstTables.Add(rs.Fields("TABLE_NAME").Value.ToString)
End If
rs.MoveNext()
Loop
rs.Close()
cn.Close()
rs = Nothing
cn = Nothing
Catch ex As Exception
MsgBox(ex.Message)
Debug.WriteLine(ex.Message)
End Try
Return lstTables
End Function
Suscribirse a:
Enviar comentarios (Atom)
VBA Access. Redondeo de números decimales con el método medio redondeo. Alternativa a la función Round (bankers round)
Private Function Redondeo(ByVal Numero As Variant, ByVal Decimales As Integer) As Double 'Aplica método medio redondeo (half round ...
-
Option Compare Database Option Explicit '***************************** ' 'Ejemplo de uso ' 'selecciona 1 ficher...
-
Option Compare Database Option Explicit 'Zip / UnZip file or folder 'http://www.codekabinett.com/rdumps.php?Lang=2&targetDoc...
No hay comentarios:
Publicar un comentario