Click here to Skip to main content
15,885,032 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all

below is my code of fetching data from database

C#
npgcommand = new NpgsqlCommand("Select * from tbl_trans where accnumber= (select account_number from tbl_acccountdetails where holder_name='" + label3.Text + "') and printed=1", npgconn);
                npgDA = new NpgsqlDataAdapter(npgcommand);

                npgDA.Fill(dt);


now after this i am printing this values.

now after this i want to update printed=0 in database.means what ever rows are coming in dt
i want to update only those values.

Please tell me how to do this.
Posted

1 solution

u can use query like below and execute it.


SQL
update  tbl_trans  set printed=0 where holder_name='" + label3.Text + "' and printed=1;


call this query after your datatable is filled.

hope this helps.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900