s_temp = "select * from user "
If Login.name2 <> "" Then
    s_temp = s_temp & "where name = '" & Login.name2 & "' "
            If Login.pass2 <> "" Then
                 s_temp = s_temp & "and password = '" & Login.pass2 & "'"
            End If
     Adodc1.RecordSource = s_temp
     Adodc1.Refresh  '报错的地方,---- 另--FROM 子句语法错误~~
    If Adodc1.Recordset.EOF Then
     MsgBox "用户名或密码错误!"
     Else
      .............
     end if

解决方案 »

  1.   

    我决定这样做不是太好,我是这样的.
    If Login.name2 <> "" Then
         Adodc1.Recordset.open "select 密码字段 form where 名字字段 = '"& login.name2 &"'"
         if adodc1.recordset.eof then
             MsgBox "用户名不存在!"
         else
             if adodc1.recordset("密码字段") <> log.pass2 
                 MsgBox "密码错误!"
             end if
         end if
    end if   
      

  2.   

    其实楼主的没有错误,是不是表名用user,这是一个关键字,建议换一下表名。
      

  3.   

    同意楼上,但是我觉得:login.name2和密码字段应该去掉两边的空格,不然取值时如果数据库中存在字段值为空格时,是会出现错误的,因为“”和 NULL 和 EMPTY 是不同的。
      

  4.   

    s_temp = s_temp & "and password = '" & Login.pass2 & "'"
    如果你这句代码是直接从你的语句上复制下来的话
    那估计可能跟你在and前没有加空格有关,即修改成:
    s_temp = s_temp & " and password = '" & Login.pass2 & "'"