vb程序出错,帮忙看一下

来源:百度知道 编辑:UC知道 时间:2024/05/30 19:34:22
Private Sub Command1_Click()
Static nErr As Integer
Dim bErr As Boolean
Dim conn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim strSql As String

If Text1.Text = "" Or Text2.Text = "" Then
MsgBox "用户或密码不能为空!", vbCritical, "错误"
bErr = True
Else
Set conn = OpenConnForSqlServer("52B097A2466C496", "bill", "")
strSql = "select * from myuser where 登录帐号= '" & Text1.Text & "' and 密码='" & Text2.Text & "'"
Set rs = OpenRecordset(strSql, conn)
If rs.EOF Then
MsgBox "错误的用户名或密码!", vbCritical, "错误"
bErr = True
Else
Unload Me
Form2.Show
End If
End If

If bErr Then
nErr = nErr + 1
If nErr = 3 Then
Unload Me
Else
Text1.Text = ""
Text2.Text = ""
Text1.SetFocus
End If
End If
End Sub

OpenConnForSqlServer这个函数没有。应该是在某个模块中,但是你没有他的这个模块中的代码。
你可以把Set conn = OpenConnForSqlServer("52B097A2466C496", "bill", "")这一条代码改成你自己相应的打开数据库的代码就可以了。