|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
语句的目的是想记录 某一段 sql 语句 进入 ACCESS 数据库.
mystrsql = "INSERT INTO [OperateLog]([operatedate],[username],[userIP],[usercomputername],[actiontype],[SQL_S]) VALUES ('" & Now() & "','" & myusername & "','" & userIP & "','" & usercomputername & "','" & actiontype & "','" & SQL_S & "')"
?mystrsql
INSERT INTO [OperateLog]([operatedate],[username],[userIP],[usercomputername],[actiontype],[SQL_S]) VALUES ('2013/9/9 17:11:18','XSA CI / Jack Ou','','','Login','SELECT * FROM [Useraccount] WHERE (usercode = 'XSACIJO')')
但当执行下面的语句时,出错.
cnn.Execute mystrsql
请问如何处理?
我只想把 SELECT * FROM [Useraccount] WHERE (usercode = 'XSACIJO') 记录 到 数据库.
myData = DB_path
mytable = "OperateLog"
cnnStr = "Provider=microsoft.jet.oledb.4.0;" _
& "Data Source=" & myData & ";" _
& "Jet OLEDB:Database Password=" & DB_password & ";"
On Error Resume Next
With cnn
.ConnectionString = cnnStr
.Open
End With
On Error GoTo 0
If cnn.State <> adStateOpen Then
MsgBox "Database access failed! Pls contact your administrator!!", vbCritical, "PPR"
Exit Sub
End If
mystrsql = "INSERT INTO [OperateLog]([operatedate],[username],[userIP],[usercomputername],[actiontype],[SQL_S]) VALUES ('" & Now() & "','" & myusername & "','" & userIP & "','" & usercomputername & "','" & actiontype & "','" & SQL_S & "')"
cnn.Execute mystrsql
|
|