代码来了:
Public Function TransactSQL(ByVal sql As String) As ADODB.Recordset
Dim con As ADODB.Connection
Dim rs As ADODB.Recordset
Dim strConnection As String
Dim strArray() As String
Set con = New ADODB.Connection '创建连接
Set rs = New ADODB.Recordset '创建记录集
On Error GoTo TransactSQL_Error
strConnection = "Provider=Microsoft.jet.oledb.4.0;Data Source=" & App.Path & "\pms.mdb"
strArray = Split(sql)
con.Open strConnection '打开连接
If StrComp(UCase$(strArray(0)), "select", vbTextCompare) = 0 Then
rs.Open Trim$(sql), con, adOpenKeyset, adLockOptimistic
Set TransactSQL = rs '返回记录集
dbFlag = 1
Else
con.Execute sql '执行命令
dbFlag = 1
End If
TransactSQL_Exit:
Set rs = Nothing
Set con = Nothing
Exit Function
TransactSQL_Error:
MsgBox "查询错误:" & Err.Description
dbFlag = 2
Resume TransactSQL_Exit
End Function
这里能出什么问题?其他模块都能正常运行,就他妈的这一点不行了!!