Inserting VB.net Label to mysql table -
how inserting label.text data mysql table. have no problem textbox.text can't figure out how label.text try same code textbox.text
parameterb_answer.value = textbox1.text it work find when try
parameterb_answer.value = label1.text mysqlreader seems can't read it.
update:
1.1.1 label1.text. idea insert text "1.1.1" label1 primary key , textbox(textbox1.text) following
my code is:
try dim strsql string = "insert boranga" & _ "(idboranga,answers)" & _ "values (@b_ida,@b_answer);" dim mycommand mysqlcommand = new mysqlcommand(strsql, conn.open) mycommand.commandtype = commandtype.text dim parameterb_ida mysqlparameter = new mysqlparameter("@b_ida", mysqldbtype.varchar, 300) parameterb_ida.value = label1.text dim parameterb_answer mysqlparameter = new mysqlparameter("@b_answer", mysqldbtype.varchar, 300) parameterb_answer.value = textbox1.text mycommand.parameters .add(parameterb_ida) .add(parameterb_answer) end dim result mysqldatareader = mycommand.executereader(commandbehavior.closeconnection) msgbox("tersimpan", vbyes, "boranga") catch sqlex mysqlexception throw new exception(sqlex.message.tostring()) end try but when change value of label1.text (1.1.1) 111, works fine. because put int column label1.text fill while "1.1.1" isn't integer
thank lot
ps:seems can't post image because low of reputation
try using code format first of all:
private sub btnlogin_click(byval sender system.object, byval e system.eventargs) handles btnlogin.click dim conn mysqlconnection 'connect database using these credentials conn = new mysqlconnection conn.connectionstring = "server=your server site (generally long url); user id=login id mysql user; password=self explanatory; database=name of db you're trying reach" 'try , connect (conn.open) try conn.open() catch myerror mysqlexception 'if fails this... (i.e. no internet connection, etc.) msgbox("error connecting database. check internet connection.", msgboxstyle.critical) end try 'mysql query (where call information) dim myadapter new mysqldataadapter 'tell find file emails/passes stored dim sqlquery = "select * database selected above email = '" & txtemail.text & "' , password = '" & txtpassword.text & "'" dim mycommand new mysqlcommand mycommand.connection = conn mycommand.commandtext = sqlquery 'start query myadapter.selectcommand = mycommand dim mydata mysqldatareader mydata = mycommand.executereader if mydata.hasrows = 0 msgbox("invalid email address or password.", msgboxstyle.critical) else msgbox("logged in " & txtemail.text & ".", msgboxstyle.information) me.close() end if end sub
and insert label.text try replacing 1 of textbox.text fields first , see if accept it. if does, answer in formatting.
also, not forget call:
imports mysql.data.mysqlclient and make sure add mysql.data reference.
Comments
Post a Comment