帮忙看一下这个vb程序 初学者
PrivateSubcmdOK_Click()StaticnErrAsIntegerDimbErrAsBooleanDimconnAsADODB.ConnectionDi...
Private Sub cmdOK_Click()
Static nErr As Integer
Dim bErr As Boolean
Dim conn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim strSql As String
If txtUser.Text = "" Or txtPwd.Text = "" Then
《 txtuser、txtpwd是textbox名吗?》
MsgBox "用户或密码不能为空!", vbCritical, "错误"
bErr = True
Else
Set conn = OpenConnForSqlServer("XSFHLZH\SQLEXPRESS", "xsfh", "")
《上面这句帮忙解释一下什么意思》
strSql = "select * from users where name = '" & txtUser.Text & "' and password='" & txtPwd.Text & "'"
Set rs = OpenRecordset(strSql, conn)
《users是什么意思,是数据库中的表,还是?》
If rs.EOF Then
MsgBox "错误的用户名或密码!", vbCritical, "错误"
bErr = True
Else
Unload Me
frmMain.Show
End If
End If
If bErr Then
nErr = nErr + 1
If nErr = 3 Then
Unload Me
Else
txtUser.Text = ""
txtPwd.Text = ""
txtUser.SetFocus
End If
End If
End Sub 展开
Static nErr As Integer
Dim bErr As Boolean
Dim conn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim strSql As String
If txtUser.Text = "" Or txtPwd.Text = "" Then
《 txtuser、txtpwd是textbox名吗?》
MsgBox "用户或密码不能为空!", vbCritical, "错误"
bErr = True
Else
Set conn = OpenConnForSqlServer("XSFHLZH\SQLEXPRESS", "xsfh", "")
《上面这句帮忙解释一下什么意思》
strSql = "select * from users where name = '" & txtUser.Text & "' and password='" & txtPwd.Text & "'"
Set rs = OpenRecordset(strSql, conn)
《users是什么意思,是数据库中的表,还是?》
If rs.EOF Then
MsgBox "错误的用户名或密码!", vbCritical, "错误"
bErr = True
Else
Unload Me
frmMain.Show
End If
End If
If bErr Then
nErr = nErr + 1
If nErr = 3 Then
Unload Me
Else
txtUser.Text = ""
txtPwd.Text = ""
txtUser.SetFocus
End If
End If
End Sub 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询