'''
''' 获取所有表的名字
'''
''' 连接对象
''' 包含表名字的字符串数组
Public Function GetTablesName(ByVal conn As OleDb.OleDbConnection) As String()
If (conn Is Nothing) AndAlso (conn.State <> ConnectionState.Open) Then
Return Nothing
End If
Dim arTmp As ArrayList = New ArrayList()
Dim dtTmp As DataTable = conn.GetSchema("Tables")
For i As Integer = 0 To dtTmp.Rows.Count - 1
'必须是基本表,不是系统表
If dtTmp.Rows(i).Item("TABLE_TYPE").ToString() = "TABLE" Then
arTmp.Add(dtTmp.Rows(i).Item("TABLE_NAME"))
End If
Next
Dim arT As String()
ReDim arT(arTmp.Count() - 1)
arTmp.CopyTo(arT)
Return arT
End Function
'''
''' 获取一个表的列名
'''
'''
''' 表明
''' 表的列名子字符串数组
Public Function GetColumnsName(ByVal conn As OleDb.OleDbConnection, ByVal TableName As String) As String()
If (conn Is Nothing) AndAlso (conn.State <> ConnectionState.Open) Then
Return Nothing
End If
Dim arTmp As ArrayList = New ArrayList()
Dim dtTmp As DataTable = conn.GetSchema("Columns", New String() {Nothing, Nothing, TableName})
For i As Integer = 0 To dtTmp.Rows.Count - 1
arTmp.Add(dtTmp.Rows(i).Item("COLUMN_NAME"))
Next
Dim arT As String()
ReDim arT(arTmp.Count() - 1)
arTmp.CopyTo(arT)
Return arT
End Function