我用ADO对象将VB和MySQL连接起来,现在我的MySQL数据库里有一个user表,两个属性:host和code,包括一些用户名和密码,而在VB中我想实现下述功能:在Text1中输入用户名(比如abc),Text2中输入密码(比如000000),如果用户名abc包含在MySQl的user表中,而密码又对应正确,则在Label1中显示“正确”。各位大侠,小弟实在是不会,谁能指教一下啊!跪谢啦!!!

解决方案 »

  1.   

    这个是最基本的记录集操作呀,dim rs as adodb.recordset 
    set rs=conn.execute("select host,code from user") 
    if not rs.eof then 
       if iif(isnull(rs!host),"",rs!host)=text1.text) and iif(isnull(rs!host),"",rs!host)=text1.text) then 
          label.caption="正确"
       else
          label.caption="错误"
       end if 
    else
       label.caption="错误"
    end if 
      

  2.   

    你能不能帮我看一下我的代码有哪些问题,程序说“类型不匹配”,谢谢啦!
    Private Sub Command4_Click()
    Set conn = New ADODB.Connection
     Set rs = New ADODB.Recordset
     conn.ConnectionString = "pvovider=MSDASQL;" + "DRIVER={MySQL ODBC 3.51 Driver};" + "Sever=202.199.241.175;Port=3306;UID=chxd;PWD=325106;" + "database=chel;Option=16387"
     conn.Open
     Set rs = conn.Execute("select host,code from user;")
    If Not rs.EOF Then
      If IIf(IsNull(rs!host), "", rs!host) = Text1.Text And IIf(IsNull(rs!code), "", rs!code) = Text2.Text Then
           label.caption="正确"
      Else
          label.caption="错误" 
      end if 
    else 
      label.caption="错误" 
    end if 
    End Sub
      

  3.   

    set rs=new recordset
    conn.open connectionstring
    rs.open "select [host] ,code from [user] where [host]='" & text1.tex & "' and code='" & text2.text & "'",conn,1,1if rs.recordset>0 then
      label.caption="Correct"
    else
      label.caption="Invalid"end if
      

  4.   

    用了一下,系统提示说rs.recordset "未找到方法或数据成员",怎么回事呢?