Login Form using sql database c# -
Login Form using sql database c# -
i'm trying create sign page . set user name , password , save in sql database.
note: evrey thing worked until add together 2nd column(the password).
this password code(the username same) :
static public void delete(string _password) { seek { connection.open(); sqlcecommand commandinsert = new sqlcecommand("insert [table] values(@password)", connection); commandinsert.parameters.add("password", _password); commandinsert.executenonquery(); } grab (sqlceexception expection) { messagebox.show(expection.tostring()); } { connection.close(); } }
and button settings :
private void button1_click(object sender, eventargs e) { if (deletebox.text != "") { sqlfunctions.insert(insertbox.text); sqlfunctions.delete(deletebox.text); sqlfunctions.refresh(this.datagridview1); } else { messagebox.show("login failed"); } }
thanks
i guess need modify code little bit this
sqlcecommand commandinsert = new sqlcecommand("insert [table] values(@username,@password)", connection);
you should pass 2 parameters have 2 fields in db , if don't want pass username should specify thing this
sqlcecommand commandinsert = new sqlcecommand("insert [table](password) values(@password)", connection);
and
commandinsert.parameters.add("password", _password);
this should written follows
commandinsert.parameters.add("@password", _password);
and pass values parameter, can this
command.parameters.addwithvalue("@password", insertbox.text);
c# sql winforms login sql-server-ce
Comments
Post a Comment