If InStr("insert,delete,updata", Trim(a(0))) Then
cN.Execute sql
Select Case Trim(a(0))
Case "insert"
msgstring = "添加记录"
Case "delete"
msgstring = "删除记录"
Case "updata"
msgstring = "更新记录"
End Select
msgstring = msgstring & "已完成"
Else
Set rst = New ADODB.Recordset
rst.CursorLocation = adUseClient
rst.Open sql, cN, adOpenKeyset, adLockOptimistic
Set chaxun = rst
msgstring = "查询到" & rst.RecordCount & "条记录"
End If
ExecuteSQL_Exit:
Set rst = Nothing
Set cN = Nothing
Exit Function
ExecuteSQL_Error:
msgstring = "查询错误: " & _
err.Description
Resume ExecuteSQL_Exit
End Function
调用
Dim xx As String
Dim yy As String
Dim mrc As ADODB.Recordset
Dim i As Long
xx = "select * from 操作员表"
Set mrc = chaxun(xx, yy)