1,216
社区成员
发帖
与我相关
我的任务
分享
selsql = "select * from constants where TREEID = " & selectId & " and SIZE = " & mid
Debug.Print selsql
Set numrst = executesql(selsql, msgtxt)
If InStr("INSERT,DELETE,UPDATE,EXECUTE", UCase$(stokens(0))) Then '
cnn.Execute (sql) '执行语句
msgstring = stokens(0) & "query successful" '返回执行结果
Else
Set rst = New ADODB.Recordset '创建结果数据集
Set rst.ActiveConnection = cnn
rst.CursorLocation = adUseClient
rst.Open Trim$(sql), cnn, adOpenKeyset, adLockOptimistic 'trim$为去掉字符串两边的空格,
Set executesql = rst
msgstring = "查询到" & rst.RecordCount & "条记录"
End If
executesql_exit:
Set rst = Nothing
Set cnn = Nothing
Exit Function
executesql_error:
msgstring = "查询错误:" & Err.Description
MsgBox "错误号:" & Err.Number & Chr(13) & Chr(10) & Err.Description '获取错误号和错误说明。
Resume executesql_exit