vb.net - visual basic - Calling information from one form to another -


form1 (login form):

private sub login_btn_click(sender object, e eventargs) handles login_btn.click     try         dim connstr string = ""         dim connection new mysqlconnection(connstr)         dim reader mysqldatareader         connection.open()         dim query string         query = "select * table username='" & txtusername.text & "' , password='" & txtpassword.text & "' "         command = new mysqlcommand(query, connection)         reader = command.executereader         dim count integer         count = 0         while reader.read             count = count + 1         end while         if count = 1             query = "select * table username= '" & txtusername.text & " '"             dim username string             username = reader("username")             messagebox.show( " " & username )              messagebox.show("username , password correct")             homepage.show()             me.hide()             txtusername.text = ""             txtpassword.text = ""         endif         connection.close() 

form2:

private sub homepage_load(sender object, e eventargs) handles mybase.load     try         dim connstr string = ""         dim connection new mysqlconnection(connstr)         dim reader mysqldatareader         connection.open()         dim query string         query = "select * table username= '" & form1.username.text & " '"         command = new mysqlcommand(query, connection)         reader = command.executereader         if (reader.read() = true)             dim username string             username = reader("username")             lblusername.text = "logged in as: " & username             connection.close()         end if     catch ex exception         msgbox(ex.message)     end try end sub 

ok, problem is, when trying username information form1, works first time. if log out, , log in username, still display same username? please can me :)

very simple fix -.-

            dim homepage = new homepage             homepage.show()              me.hide() 

Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

Cross-Compiling Linux Kernel for Raspberry Pi - ${CCPREFIX}gcc -v does not work -

java.lang.NoClassDefFoundError When Creating New Android Project -