爱一个人不一定要拥有她 拥有一个人就一定要好好的爱她
楼主可以不可以把这段代码解释一下
Public Function ExecuteSQL(ByVal SQL As String) As ADODB.Recordset
Dim cnn As New ADODB.Connection
Dim rst As ADODB.Recordset
Dim sTokens() As String
On Error GoTo Error_Do
cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\kfp.mdb;Persist Security Info=False"
sTokens() = Split(SQL)
If InStr("INSERT,DELETE,UPDATE", UCase(sTokens(0))) Then
cnn.Execute SQL ----主要是这里
Else
Set rst = New ADODB.Recordset
With rst
.ActiveConnection = cnn
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.LockType = adLockOptimistic
.Open Trim(SQL)
End With
'rst.Open Trim(SQL), cnn, adOpenStatic, adLockOptimistic
Set ExecuteSQL = rst
End If
Set cnn = Nothing
Set rst = Nothing
Exit Function
Error_Do:
Dim Err_Str As String
Err_Str = "服务器" & Err.Description
If MsgBox(Err_Str, vbRetryCancel + vbCritical, "警告") = vbRetry Then
Resume
Else
Set cnn = Nothing
Set rst = Nothing
End
End If
End Function
还有检测用户名是否存在为什么要这么复杂`?