Set rs = New ADODB.Recordsetrs.Open "select 用户名,密码 from 密码表 where 用户名= " ' & Combo1.Text'" "and 密码=" "'& Text1.text'""我主要是想在 密码表里查询 用户名=Combo1里的内容并且密码=Text1里的内容  的纪录
但是我不知道语句中双引号和单引号还有&符号的格式怎么写。

解决方案 »

  1.   

    rs.Open "select 用户名,密码 from 密码表 where 用户名= '" & replace(Combo1.Text,"'","''") & "'and 密码='" & replace(Text1.text,"'","''") & "'",1,1
      

  2.   

    rs.Open "select 用户名,密码 from 密码表 where 用户名='"& Combo1.Text&"' and 密码='"& Text1.text &"'"
      

  3.   

    正确语句
    rs.Open "select 用户名,密码 from 密码表 where 用户名='aaa' and 密码='bbb'"
    使用变量
    aaa 为 Combo1.Text
    带入格式
    “& Combo1.Text &”
      

  4.   

    Public cn As New ADODB.Connection
    cn.Provider = "microsoft.jet.oledb.4.0"
    cn.Open "c:\data.mdb"Set rs = New ADODB.Recordset
    rs.Open "select 用户名,密码 from 密码表 where 用户名='aaa' and 密码='bbb'",cn, adOpenKeyset, adLockOptimisticrs.open sql语句,连接Conn,光标类型,锁定类型
      

  5.   

    建議找本書看看
    如果你的字段是字符型就要在查詢的時候用單引號將所給的值括起來
    如 rs.open "Select ...  Where 用戶名='XXX'"
    如果你要使用變量的話,也是一樣的,改成 
       Rs.open "Select ...  Where 用戶名='" & 變量 & "'"
     兩邊的單引號還是不能少的,加雙引號的目的只是為了使 "Select ...  Where 用戶名='" & 變量 & "'" 變成一個完整的<或者應該說是合法的>字符串
    你也可以先用
      Dim SqlStr As String
       SqlStr="Select ... Where 用戶名='" & Combo1.text & "' And 密碼='" & TxtPwd.text & "'"
      然后用 
       Msgbox sqlstr
      如果成功的話可以
      Rs.open sqlstr
      

  6.   

    rs.Open "select 用户名, 密码 from 密码表 where 用户名= '" & Combo1.Text & "' and 密码= '" & Text1.text "'"//注意全角与半角,双引号是VB中的语法,单引号是要生成SQL语句提交到数据库去执行的,&是VB中的字符串连接符!!
      

  7.   

    若密码是字符型则用'" & text1.text & "'
        若是数值型则用" & text1.text & "
      

  8.   

    rs.Open "select 用户名,密码 from 密码表 where 用户名= '" & Combo1.Text "' and 密码= '" & Text1.text & "'"
      

  9.   

    '" & ******& "'     '*你要加的东西!
      

  10.   

    蠢蠢 少了一个&
    rs.Open "select 用户名,密码 from 密码表 where 用户名= '" & Combo1.Text& "' and 密码= '" & Text1.text & "'"
      

  11.   

    楼主 别误会哈 我说的是   RUKYO(SpeakFool - 蠢蠢的男子汉)