If Trim(user.Text) = "" Then
MsgBox "用户名不能为空,请输入用户名!", vbOKOnly + vbExclamation, "注意"
user.SetFocus
exit sub
end if
SQL ="select * from user where username='"&user.text&"'"(这条语句提示我没有完成是怎么回事???)
Set mrc = cnn.Execute(SQL)
MsgBox "用户名不能为空,请输入用户名!", vbOKOnly + vbExclamation, "注意"
user.SetFocus
exit sub
end if
SQL ="select * from user where username='"&user.text&"'"(这条语句提示我没有完成是怎么回事???)
Set mrc = cnn.Execute(SQL)
cnn.Open "FileDSN=旧车市场系统.dsn;"If Trim(user.Text) = "" Then
MsgBox "用户名不能为空,请输入用户名!", vbOKOnly + vbExclamation, "注意"
user.SetFocus
Else
SQL = "select * from user where username='" & User.Text & "'" '(这条语句提示我没有完成是怎么回事)
'错误原因:你少了空格!!在& 与 User.Text 之间!!!!!!!Set mrc = cnn.Execute(SQL)
cnn.Open "FileDSN=旧车市场系统.dsn;"If Trim(user.Text) = "" Then
MsgBox "用户名不能为空,请输入用户名!", vbOKOnly + vbExclamation, "注意"
user.SetFocus
Else
SQL = "select * from user where username='" & User.Text & "'" '(这条语句提示我没有完成是怎么回事)
'错误原因:你少了空格!!在& 与 User.Text 之间!!!!!!!Set mrc = cnn.Execute(SQL)
Dim sql As String
Dim mrc As ADODB.RecordsetSet cnn = New ADODB.Connection
cnn.Open "FileDSN=旧车市场系统.dsn;"If Trim(user.Text) = "" Then
MsgBox "用户名不能为空,请输入用户名!", vbOKOnly + vbExclamation, "注意"
user.SetFocus
Else
sql = "select * from user where username='" & user.Text & "'"
Set mrc = cnn.Execute(sql)
If mrc.EOF = True Then
MsgBox "没有这个用户,请重新输入用户名!", vbOKOnly + vbExclamation, "注意"user.SetFocus
Else
If Trim(mrc.Fields(1)) = Trim(user.Text) Then
ok = True
mrc.Close
Me.Hide
username = Trim(user.Text)
Else
MsgBox "输入密码不正确,请重新输入!", vbOKOnly + vbExclamation, "注意"
user.SetFocus
user.Text = ""
End If
End If
End IfSet mrc = cnn.Execute(sql)在这行提示我:
[Microsoft][ODBC SQL Server Driver][SQL Server]在关键字'user'附近有语法错误.
这是怎么回事请告诉我一下谢谢大家了
"ad..",石油系统自动列出的成员,分别由四个,两个参数你都可以随便选一个
Dim cnn As ADODB.Connection
Dim Strsql As String
Dim mrc As ADODB.RecordsetSet cnn = New ADODB.Connection
cnn.Open "FileDSN=旧车市场系统.dsn;"If Trim(user.Text) = "" Then
MsgBox "用户名不能为空,请输入用户名!", vbOKOnly + vbExclamation, "注意"
user.SetFocus
Else
'***********************
Strsql = "select * from [user] where [username]='" & user.Text & "'"
Set mrc = cnn.Execute(Strsql)
If mrc.EOF = True Then
MsgBox "没有这个用户,请重新输入用户名!", vbOKOnly + vbExclamation, "注意"user.SetFocus
Else
If Trim(mrc.Fields(1)) = Trim(user.Text) Then
ok = True
mrc.Close
Me.Hide
username = Trim(user.Text)
Else
MsgBox "输入密码不正确,请重新输入!", vbOKOnly + vbExclamation, "注意"
user.SetFocus
user.Text = ""
End If
End If
End If
如果你用Access作数据库:
Dim conMainMdb As New ADODB.Connection
Dim rstMainMdb As New ADODB.Recordset
conMainMdb.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & App.Path & "\MainMDB.mdb;Persist Security Info=False"
conMainMdb.Open
With rstMainMdb .CursorLocation = adUseClient
.CursorType = adOpenDynamic
.LockType = adLockOptimistic
.ActiveConnection = conMainMdb
.Open "SELECT * FROM [check] order by 编号 "
End With