vb登陆界面总是提示密码错误

来源:百度知道 编辑:UC知道 时间:2024/06/01 12:59:28
Private Sub Command1_Click()
Dim miCount As Integer
Dim sqlstr As String

sqlstr = "select*from 密码表 where 用户名='" & Text1.Text & "'"
Adodc1.RecordSource = sqlstr
Adodc1.Refresh
Debug.Print sqlstr
Debug.Print Text2.Text

If Adodc1.Recordset.BOF Then
MsgBox "用户名错误,请重新输入", vbExclamation, "警告"
Text1.Text = ""
Text1.SetFocus

Else
If Text2.Text = Adodc1.Recordset.Fields("密码") Then

MDIForm1.Visible = True
MDIForm1.mDManagement.Enabled = True
MDIForm1.mControl.Enabled = True
MDIForm1.mMenu.Enabled = True
frmMenu.Visible = True
frmChange.Show

Else

MsgBox "密码错误,重新输入", vbExclamation, "警告"
Text2.Text = ""
Text2.SetFocus

End If
End If

miCount =

先看看 sqlstr 出来是什么啊:) 可能没去空格吧?:)
sqlstr = "select*from 密码表 where 用户名='" & trim(Text1.Text) & "'"

sqlstr = "select*from 密码表 where 用户名='" & Text1.Text & "'"
中的select*from掉空格了,应该为select * from .