mysql - How to store user input of Username and Password to phpmyadmin in VB? -


i'm writing program asks user input username , password database on localhost uses phpmyadmin. tried following tutorial on how it: https://www.youtube.com/watch?v=jzstllfonuo , can connect database fine, think problem sql statement. here code form:

imports mysql.data.mysqlclient   public class frmsignup dim serverstring string = "server=localhost;user    id=;password=;database=accountinfo" dim sqlconnection mysqlconnection = new mysqlconnection  private sub form3_load(sender object, e eventargs) handles mybase.load     sqlconnection.connectionstring = serverstring      try         if sqlconnection.state = connectionstate.closed             sqlconnection.open()             msgbox("successfully connected db")          else             sqlconnection.close()             msgbox("failed connect db")         end if     catch ex exception         msgbox(ex.tostring)      end try end sub  public sub saveaccountinformation(byref sqlstatement string)     dim cmd mysqlcommand = new mysqlcommand      cmd         .commandtext = sqlstatement         .commandtype = commandtype.text         .connection = sqlconnection         .executenonquery()     end     sqlconnection.close()     msgbox("successfully registered account!")     sqlconnection.dispose() end sub  private sub btnsignup_click(sender object, e eventargs) handles btnsignup.click     if txtpasswd.text = txtpasswd2.text         messagebox.show("passwords match!")                     dim sqlstatement1 string = "insert `accountinfodb` (`usernames`, `passwords`) values ('', '')"       else         messagebox.show("passwords not match!")         txtpasswd.text = focus()         txtpasswd.clear()         txtpasswd2.text = focus()         txtpasswd2.clear()      end if end sub end class 

my database called "account information" table called "accounts" wanted store username , password.

so overall question is, how store information(username & password) phpmyadmin? i've tried looking on google, no avail have found anything. if me succeed awesome, thank you!

edit 1

so have error in sql syntax, i'm 99% sure it's sql statement in code incorrect when storing username , password.

       dim sqlstatement1 string = "insert accountinfo(accountinfodb) (`usernames`, `passwords`) values ('" & txtpasswd.text & txtusername.text & "')" 

gives me error:

an unhandled exception of type 'mysql.data.mysqlclient.mysqlexception' occurred in mysql.data.dll

additional information: have error in sql syntax; check manual corresponds mariadb server version right syntax use near 'usernames, passwords) values ('123123')' @ line 1

when type 123 username, , 123 password.

dim sqlstatement1 string = "insert accountinfo(accountinfodb) (passwords,usernames) values ('" & txtpasswd.text "', '" & txtusername.text & "')" 

but if want more security (sql injection attack)

    dim serverstring string = "server=localhost;user id=;password=;database=accountinfo"     dim query string = "insert accountinfo(accountinfodb) (passwords,usernames) values (@txtpasswd, @txtusername)"     cmd = new mysqlcommand(query, serverstring)     cmd.commandtype = commandtype.text     cmd.parameters.add("@txtpasswd", sqldbtype.varchar, 255).value = txtpasswd.text     cmd.parameters.add("@txtusername", sqldbtype.varchar, 255).value = xtusername.text     cmd.executenonquery() 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -