有个VB问题,请高人指点。

前端之家收集整理的这篇文章主要介绍了有个VB问题,请高人指点。前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

下面这个题运行的时候为什么会提示少了IF?

Public Function Executesql(ByVal sql As String,MsgString As String) As ADODB.Recordset Dim cnn As ADODB.Connection Dim rst As ADODB.Recordset Dim sTokens() As String On Error GoTo Executesql_Error sTokens = Split(sql) Set cnn = New ADODB.Connection cnn.Open ConnectString If InStr("INSERT,DELETE,UPDATE,EXECUTE",UCase$(sTokens(0))) Then cnn.Execute (sql) MsgString = sTokens(0) & "query successful" Else Set rst = New ADODB.Recordset rst.Open Trim$(sql),cnn.adOpenKeyset,adLockOptimistic Set Executesql = rst MsgString = "查询到" & rst.RecordCount & "条记录" End If Executesql_Exit: Set rst = Nothing Set cnn = Nothing Exit Function Executesql_Error: MsgString = "查询错误:" & Err.Description Resume Executesql_Exit End Function

原文链接:https://www.f2er.com/vb/262955.html

猜你在找的VB相关文章