Private Sub Command1_Click()
Dim cnMobileSales As ADOCE.Connection
Dim strPath As String
Dim rs As ADOCE.Recordset
Set cnMobileSales = CreateObject("ADOCE.Connection.3.0")
Set rs = CreateObject("ADOCE.Recordset.3.0")
' 连接是否已成功?
strPath = App.Path + "\MobileMIS.cdb"
MsgBox strPath
cnMobileSales.Open "data source=" & strPath
If cnMobileSales.Errors.Count > 0 Then
MsgBox "连接到数据库时出错。" & vbCrLf & _
"错误" & Err.Number & vbCrLf & _
Err.Description & _
vbCritical, "打开数据库"
Set cnMobileSales = Nothing
On Error GoTo 0
App.End
Else
MsgBox "Connected!!!OK"
End If
Dim strsql As String
Dim inti As Integer
Dim strData As String
inti = 0
strsql = "select * from '教室资料表'"
Set rs = cnMobileSales.Execute(strsql)
rs.Open strsql, cnMobileSales, adOpenForwardOnly, adLockReadOnly
If rs.RecordCount > 0 Then
Text1.Text = rs.Fields(0).Name
End If
MsgBox strData
End Sub
运 行报错!!!
an error was encountered
while running this program
the specified table does not exist