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)

解决方案 »

  1.   

    user.text 改成 replace(user.text,"'","''")
      

  2.   

    user.text 改成 replace(user.text,"'","’")将引号改成全角
      

  3.   

    set 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 & "'"  '(这条语句提示我没有完成是怎么回事)
    '错误原因:你少了空格!!在& 与 User.Text 之间!!!!!!!Set mrc = cnn.Execute(SQL)
      

  4.   

    set 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 & "'"  '(这条语句提示我没有完成是怎么回事)
    '错误原因:你少了空格!!在& 与 User.Text 之间!!!!!!!Set mrc = cnn.Execute(SQL)
      

  5.   

    Dim cnn As ADODB.Connection
    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'附近有语法错误.
    这是怎么回事请告诉我一下谢谢大家了
      

  6.   

    你把aql的最后值,告诉我们
      

  7.   

    SQL = "select * from [user] where username='" & User.Text & "'"  '(这条语句提示我没有完成是怎么回事)
      

  8.   

    SQL ="select * from user where username='"&user.text&"'",cnn,ad..,ad..
    "ad..",石油系统自动列出的成员,分别由四个,两个参数你都可以随便选一个
      

  9.   

    改为:
    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
      

  10.   

    建议不要使用FileDSN,灵活性不大,程序安装麻烦
    如果你用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