sql - C# Visual Studio No value given for one or more required parameters -
if (kmatch == 1) { con.open(); int a; = convert.toint16(txtbalance.text); = int.parse(txtbalance.text); oledbcommand com = new oledbcommand(); com.connection = con; string query = "update playeraccount set balance='" + + "'where player_user=" + txtuser.text + ""; com.commandtext = query; com.executenonquery(); messagebox.show("pointcard credited account"); con.close(); } at first thought needed converted int. out of ideas.
database table:playeraccount
'balance' int
just started learning this. appreciated.
you should change string query = "update playeraccount set balance='" + + "'where player_user=" + txtuser.text + ""; string query = "update playeraccount set balance= " + + " player_user='" + txtuser.text + "'";.
you need include single quotes around text values in sql , don't need include them around numeric values (though can if wish).
however, looks opening sql injection attacks.
look using parameterized commands instead of dynamically writing sql.
documentation sql parameters here.
Comments
Post a Comment