如何把access数据库所有的表名读出来存到一个字符串数组中?谢谢
解决方案 »
- 程序生成的内容拷贝到记事本中是乱码!
- 在access中添加字段并设置新字段的值。
- vb打水晶报表问题
- 100分.关于类的处理!!!
- vb中的两个小问题,麻烦解答
- 如何控制打印机??? 挺专业的问题, 一般人遇不到,专业人士来赐教. 不专的来学习
- 怎样用VB程序获得一份word文档的总页数?
- 我们到底在为谁工作!
- 问题:我们用getdc(0)取得的是全桌面的DC,怎样取得一个DC,它不包括任务栏..就像WIN98 移动窗体时出现的虚线框不会画在任务栏上一样.....getdC(getDesktopwindow)也不行.
- 怎样实现DHtmlEdit控件中热点功能?
- VB6下使用ACCESS下replace
- of123() 请进,还是关于定位目录的问题
' DAO:
'*****Public Function NonSystemTables(dbPath As String) As Collection'Input: Full Path to an Access Database'Returns: Collection of the names
'of non-system tables in that database
'or Nothing if there is an error'Requires: a reference to data access
'objects (DAO) in your projectOn Error GoTo ErrHandlerDim td As DAO.TableDef
Dim db As DAO.Database
Dim colTables As CollectionSet db = workspaces(0).opendatabase(dbPath)Set colTables = New Collection For Each td In db.TableDefs If td.Attributes >= 0 And td.Attributes <> dbHiddenObject _
And td.Attributes <> 2 Then
colTables.Add td.Name
End If
Next
db.close
Set NonSystemTables = colTablesExit Function
ErrHandler:
On Error Resume Next
If Not db Is Nothing Then db.CloseSet NonSystemTables = NothingEnd Function'*****
' ADO:
'*****
Public Sub OpenSchemaX() Dim cnn1 As ADODB.Connection
Dim rstSchema As ADODB.Recordset
Dim strCnn As String
Set cnn1 = New ADODB.Connection
strCnn = "driver={SQL Server};server=srv;" & _
"uid=sa;pwd=;database=pubs"
cnn1.Open strCnn
Set rstSchema = cnn1.OpenSchema(adSchemaTables)
Do Until rstSchema.EOF
Debug.Print "Table name: " & _
rstSchema!TABLE_NAME & vbCr & _
"Table type: " & rstSchema!TABLE_TYPE & vbCr
rstSchema.MoveNext
Loop
rstSchema.Close
cnn1.Close
End Sub'******
' ADOX:
'******
Private Sub PrintTableName()
Dim cat As New ADOX.Catalog cat.ActiveConnection = "Provider='Microsoft.Jet.OLEDB.4.0';" & _
"Data Source= 'c:\Program Files\Microsoft Office\" & _
"Office\Samples\Northwind.mdb';"
For i = 0 To cat.Tables.Count - 1
If cat.Tables(i).Type = "TABLE" Then
Debug.Print cat.Tables(i).Name
End If
Next i
End Sub