为什么我把程序拿到别的电脑上会出现这样的问题?

Private Sub cmdOK_Click()
Dim txtSQL As String
Dim mrc As ADODB.Recordset
Dim MsgText As String

UserName = ""
If Trim(txtUserName.Text = "") Then
MsgBox "用户名不能为空!", vbOKOnly + vbExclamation, "警告"
txtUserName.SetFocus
Else
txtSQL = "select * from user_Info where user_ID = '" & txtUserName.Text & "'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
If mrc.EOF = True Then
MsgBox "没有这个用户,请重新输入用户名!", vbOKOnly + vbExclamation, "警告"
txtUserName.SetFocus
Else
If Trim(mrc.Fields(1)) = Trim(txtPassword.Text) Then
ok = True
mrc.Close
Me.Hide
UserName = Trim(txtUserName.Text)
Else
MsgBox "输入密码不正确,请重新输入!", vbOKOnly + vbExclamation, "警告"
txtPassword.SetFocus
txtPassword.Text = ""
End If
End If
End If

micount = micount + 1
If micount = 3 Then
Me.Hide
End If
Exit Sub
End Sub

德玛西亚99
浏览 134回答 2
2回答

元芳怎么了

检查一下你的ExecuteSQL应该是你电脑上的数据库环境和另外那台电脑上的不一样, 所以造成ExecuteSQL返回了一个Nothing, 导致mrc 是Nothing, 然后就出错了

Smart猫小萌

不知你的ExecuteSQL过程是什么样的。可以试试Dim mrc As ADODB.Recordset改成 Dim mrc As new ADODB.Recordset
打开App,查看更多内容
随时随地看视频慕课网APP