VB6连接access2010后,提示from子句语法错误
请高手赐教,问题出在哪里?我用VB6.0连接ACCESS2010数据库,连接函数如下:PublicFunctionAccConn(CnnAsADODB.Connectio...
请高手赐教,问题出在哪里?
我用VB6.0连接ACCESS2010数据库,连接函数如下:
Public Function AccConn(Cnn As ADODB.Connection) As Boolean '连接数据库
On Error GoTo Err
Dim strSQL As String
AccConn = False
strSQL = "provider=microsoft.ace.oledb.12.0;data source=" & App.Path & "\DataBase.accdb"
With Cnn
.Mode = adModeReadWrite ' 连接模式 ???
.ConnectionTimeout = 10 '超时
.CommandTimeout = 5
.CursorLocation = adUseClient
.Open strSQL '打开数据库连接
End With
AccConn = True
Exit Function
Err:
MsgBox Err.Description, vbOKOnly + vbCritical, "数据库连接错误"
End Function
然后在连接具体表时,出现这个错误
Dim strSQL As String
Dim rs As New ADODB.Recordset
Dim HTWEA As New ADODB.Connection
If AccConn(HTWEA) = False Then MsgBox "数据库连接失败", vbOKOnly + vbCritical, "错误提示": Exit Sub
strSQL = "SELECT * FROM USER WHERE NAME='MICHAEL'"
rs.Open strSQL, HTWEA, 1, 1
PS.上面的SQL代码在ACCESS里查询没问题。
请不吝赐教!谢谢! 展开
我用VB6.0连接ACCESS2010数据库,连接函数如下:
Public Function AccConn(Cnn As ADODB.Connection) As Boolean '连接数据库
On Error GoTo Err
Dim strSQL As String
AccConn = False
strSQL = "provider=microsoft.ace.oledb.12.0;data source=" & App.Path & "\DataBase.accdb"
With Cnn
.Mode = adModeReadWrite ' 连接模式 ???
.ConnectionTimeout = 10 '超时
.CommandTimeout = 5
.CursorLocation = adUseClient
.Open strSQL '打开数据库连接
End With
AccConn = True
Exit Function
Err:
MsgBox Err.Description, vbOKOnly + vbCritical, "数据库连接错误"
End Function
然后在连接具体表时,出现这个错误
Dim strSQL As String
Dim rs As New ADODB.Recordset
Dim HTWEA As New ADODB.Connection
If AccConn(HTWEA) = False Then MsgBox "数据库连接失败", vbOKOnly + vbCritical, "错误提示": Exit Sub
strSQL = "SELECT * FROM USER WHERE NAME='MICHAEL'"
rs.Open strSQL, HTWEA, 1, 1
PS.上面的SQL代码在ACCESS里查询没问题。
请不吝赐教!谢谢! 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询