How do I reuse a SQLCommand for say multiple queries?
e.g
SqlCommand mycommand = new SqlCommand("SElect * from BKLAH", myConnection);
mycommand.ExecuteNonQuery();
Now I want to use mycommand again but use a different SQL query. How would I do this?
You can set CommandText
property of your command, like this:
mycommand.CommandText = @"UPDATE BKLAH SET a = 5 WHERE id=@id";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With