level 2
booker1234
楼主
就是这段:(验证用户名和密码的程序。用的是SQLSERVER2000,WINDOW2000) Dim txtSQL As String Dim mrc As ADODB.Recordset Dim MsgText As String txtSQL = "select * from user_Info where user_ID = '"&txtUserName.Text & "'" Set mrc = ExecuteSQL(txtSQL, MsgText) If mrc.EOF = True Then执行后有一个黄条条在 “ If mrc.EOF = True Then”上面!然后出现:“Object variable or With block variable not set (Error 91)”请大虾们指点迷津!附录:自定义函数ExecuteSQL(txtSQL, MsgText)的代码: Public Function ExecuteSQL(ByVal SQL _ As String, MsgString As String) _ As ADODB.RecordsetsTokens = Split(SQL) Set cnn = New ADODB.Connection cnn.Open ConnectString(此连接代是:ConnectString= "FileDSN=studentinfo.dsn;UID=sa;PWD=") If InStr("INSERT,DELETE,UPDATE", _ 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 'rst.MoveLast 'get RecordCount Set ExecuteSQL = rst MsgString = "查询到" & rst.RecordCount & _ " 条记录 " End If
2004年11月22日 08点11分
1