VB与MySQl连接问题

chxdinter2002 2009-06-01 03:56:54
我用ADO对象将VB和MySQL连接起来,现在我的MySQL数据库里有一个user表,两个属性:host和code,包括一些用户名和密码,而在VB中我想实现下述功能:在Text1中输入用户名(比如abc),Text2中输入密码(比如000000),如果用户名abc包含在MySQl的user表中,而密码又对应正确,则在Label1中显示“正确”。各位大侠,小弟实在是不会,谁能指教一下啊!跪谢啦!!!
...全文
74 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
chxdinter2002 2009-06-02
  • 打赏
  • 举报
回复
用了一下,系统提示说rs.recordset "未找到方法或数据成员",怎么回事呢?
clear_zero 2009-06-01
  • 打赏
  • 举报
回复
set rs=new recordset
conn.open connectionstring
rs.open "select [host] ,code from [user] where [host]='" & text1.tex & "' and code='" & text2.text & "'",conn,1,1

if rs.recordset>0 then
label.caption="Correct"
else
label.caption="Invalid"

end if
chxdinter2002 2009-06-01
  • 打赏
  • 举报
回复
你能不能帮我看一下我的代码有哪些问题,程序说“类型不匹配”,谢谢啦!
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
贝隆 2009-06-01
  • 打赏
  • 举报
回复
。。。。。
帮顶
suppercruiser 2009-06-01
  • 打赏
  • 举报
回复
这个是最基本的记录集操作呀,

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

1,217

社区成员

发帖
与我相关
我的任务
社区描述
VB 数据库(包含打印,安装,报表)
社区管理员
  • 数据库(包含打印,安装,报表)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧