我在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