连接access老说from语法错误,但我差了没有错误啊
那段程序连接sql都好使,怎么现在老错呢?
下面的程序是用来登录的。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 where user_name= '" & txtUserName & "'" //估计错误的地方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.Clone
Me.Hide
UserName = Trim(txtUserName.Text)
Else
MsgBox "密码错误,请重新输入!", vbOKOnly + vbExclamation, "警告"
txtPassword.SetFocus
txtPassword = ""
End If
End If
End If
miCount = miCount + 1
If miCount = 3 Then
Me.Hide
End If
End Sub
那段程序连接sql都好使,怎么现在老错呢?
下面的程序是用来登录的。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 where user_name= '" & txtUserName & "'" //估计错误的地方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.Clone
Me.Hide
UserName = Trim(txtUserName.Text)
Else
MsgBox "密码错误,请重新输入!", vbOKOnly + vbExclamation, "警告"
txtPassword.SetFocus
txtPassword = ""
End If
End If
End If
miCount = miCount + 1
If miCount = 3 Then
Me.Hide
End If
End Sub
If Trim(txtUserName.Text) = "" Then
应改为
txtSQL = "select * from user where user_name= '" & txtUserName.text & "'"
MsgBox "没有这个用户,请重新输入用户名!", vbOKOnly + vbExclamation, "警告"
txtUserName.SetFocus
Else
Username = txtUsername.text
txtSQL = "select * from user where user_name= '" & UserName & "'" Set mrc = ExecuteSQL(txtSQL, MsgText)
----------
----------
------------
原因在于user的表名不能用
改了表名后就行了
谢谢各位的帮忙啊
MsgBox "没有这个用户,请重新输入用户名!", vbOKOnly + vbExclamation, "警告"
txtUserName.SetFocus
Else
txtSQL = "select * from myuser where user_name= '" & trim(txtUserName.text) & "'"
'最好把表名改一下,改成myuser,还有txtUserName你少写一个text属性
Set mrc = ExecuteSQL(txtSQL, MsgText)If mrc.EOF Then
MsgBox "没有这个用户,请重新输入用户名!", vbOKOnly + vbExclamation, "警告"
txtUserName.SetFocus