Dim cnn As ADODB.Connection'定義鏈接Dim rst As ADODB.Recordset'定義字符串'Dim sTokens() As String'異常處理Public Function ExecuteSQL(ByVal SQL As String, MsgString As String) As ADODB.RecordsetOn Error GoTo ExecuteSQL_Error'用Split函數(shù)產(chǎn)生一個(gè)包含各個(gè)子串的數(shù)組sTokens = Split(SQL)'創(chuàng)建鏈接Set cnn = New ADODB.Connection'打開(kāi)鏈接cnn.Open connectString'判斷字符串中是否含有指定內(nèi)容If InStr("INSERT,DELETE.UPDATE", UCase$(sTokens(0))) Then'執(zhí)行查詢語(yǔ)句cnn.Execute SQL'返回查詢信息'MsgString = sTpkens(0) & "query successful"ElseSet rst = New ADODB.Recordset'返回查詢結(jié)果rst.Open Trim$(SQL), cnn, _anOpenKeysset, _adLLockOptimistic'rst.MoveLast 'getRecordCount & _"條記錄"End IfExecuteSQL_Exit
函數(shù)顯示未定義該怎么解決?感覺(jué)好多錯(cuò)誤哈
開(kāi)心每一天1111
2023-03-03 18:14:18