C# re-using SQLCommand
How do I reuse a SQLCommand for say multiple queries?
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";