我在mysql5.0中创建了一个数据库。我想显示它的数据。它有一个名为login的表。它有2列用户名和密码。在窗体中我有2个文本字段用户名和密码我只是想验证与数据库值和显示消息框输入。从vb到数据库的连接已成功建立。但它没有验证输入。它的错误是'需要对象'。请任何身体帮助,我是新来的vb。vb6显示问题
我使用VB6和MYSQL5.0 谢谢
代码:
public con As ADOB.connection
public rs2 As new ADOB.Recordest
public sub preconnection()
set con = New connection
set rs = New recordest
set con = New ADOB.connection
con.connectionString = "DRIVER = {Mysql ODBC 3.51 driver};"_
& "SERVER = localhost;"_
& "DATABASE = vbtest;"_
& "UID = root;"_
& "PWD = ;"
con.cursorLocation =
con.open
end sub
sql = "select *from login"
set rs = con.execute (sql)
if rs.BOF = False Then
While Not rs.EOF
If Ucase(txtlogin.text = trim(rs(0)) Ad txtpassword.text = Trim(rs(1)) Then
username = rs(0)
loginname = True
MsgBox("welcome")
End if
rs.movenext
wend
End Sub
哪条线是给你的错误? – 2010-03-19 12:18:20