C# re-using SQLCommand

c#, sql

Solution

You can set `CommandText` property of your command, like this:

mycommand.CommandText = @"UPDATE BKLAH SET a = 5 WHERE id=@id";

Problem

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?

Original source