要看是什么库咯,Access就用DAO,如果是SQl呢,用ADO就行'检测数据表是否完整,不完整就建立: Public Function CheckTable(Tables() As String) As Boolean On Error GoTo ErrTag Dim Rs As New ADODB.Recordset Dim strSql As String 'Set Rs = FConn.OpenSchema(adSchemaTables) CheckTable = True For i = 0 To UBound(Tables) '判断相应的表是否存在。 strSql = "SELECT name,id FROM sysobjects WHERE id = object_id('" & Tables(i) & "') AND type = 'U'" Rs.Open strSql, FConn, adOpenKeyset, adLockReadOnly If Rs.RecordCount = 0 Then '表不存在! InitTable Tables(i) '创建相应的表。 End If Rs.Close Next Set Rs = Nothing Exit Function ErrTag: CheckTable = False Set Rs = Nothing End Function有什么字段应该很好取得吧 打开一个记录集就行,枚举集合Rs.fields就可以得到
"select * from sysobjects where name='oldxiazaijilu'"
Public Function CheckTable(Tables() As String) As Boolean
On Error GoTo ErrTag
Dim Rs As New ADODB.Recordset
Dim strSql As String
'Set Rs = FConn.OpenSchema(adSchemaTables)
CheckTable = True
For i = 0 To UBound(Tables)
'判断相应的表是否存在。
strSql = "SELECT name,id FROM sysobjects WHERE id = object_id('" & Tables(i) & "') AND type = 'U'"
Rs.Open strSql, FConn, adOpenKeyset, adLockReadOnly
If Rs.RecordCount = 0 Then '表不存在!
InitTable Tables(i) '创建相应的表。
End If
Rs.Close
Next
Set Rs = Nothing
Exit Function
ErrTag:
CheckTable = False
Set Rs = Nothing
End Function有什么字段应该很好取得吧
打开一个记录集就行,枚举集合Rs.fields就可以得到
Next i