postgresql - Trying to update column on C# using Npgsql -


i'm trying update value of column using npgsql (postgresql) , visual studio 2015. "forgot password?" form.

the user needs enter 2 variables in order accomplish reset (an if condition): 1. enter ssn (aka rg in brazil); , 2. enter user-specific code unchangeable.

what happens is: when try change value (using command below), nothing happens.

npgsqlcommand command = new npgsqlcommand("update dbschema.dbtable set senha = '" + textbox2.text + "' rg = '" + textbox2.text + "'"); 

the if condition executes (i tied if command message box, shows password has been reseted - sign if condition indeed executed) - thing doesn't happen right password update (which might minor feature in release, i'd prefer reset myself on database). tried several changes in code, no success yet.

thanks in advance help.

lucas

you have open database connection , execute command, e.g.:

using (var conn = new npgsqlconnection(<connection string>)) {     var command = new npgsqlcommand("update dbschema.dbtable set senha = '" + textbox2.text + "' rg = '" + textbox2.text + "'", conn);     conn.open();     command.executenonquery(); } 

note way pass parameters open sql injection attacks. should @ parameterized queries.


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -