S
Sheila Jones
Hello,
I have created an OleDbCommand as follows:
OleDbCommand cmd = new OleDbCommand("SELECT * FROM PRODUCTS WHERE ID=?",
con);
cmd.Parameters.Add("@id", OleDbType.Char);
cmd.Parameters["@id"].Value="CDTR";
I then use a DataReader to read the result, process it and close the reader.
Then I change the command text:
cmd.CommandText="SELECT * FROM ORDERS WHERE ID=?";
The @id parameter still exists from the previous version and is the correct
type, so I am reusing it:
cmd.Parameters["@id"].Value="CHBRWN";
Then I use another ExecuteReader call to fetch the result. It seems to work
OK, but my question is: Is it OK to reuse the parameter like this, or should
I delete and recreate it? Or should I be using two separate command objects?
Thanks.
I have created an OleDbCommand as follows:
OleDbCommand cmd = new OleDbCommand("SELECT * FROM PRODUCTS WHERE ID=?",
con);
cmd.Parameters.Add("@id", OleDbType.Char);
cmd.Parameters["@id"].Value="CDTR";
I then use a DataReader to read the result, process it and close the reader.
Then I change the command text:
cmd.CommandText="SELECT * FROM ORDERS WHERE ID=?";
The @id parameter still exists from the previous version and is the correct
type, so I am reusing it:
cmd.Parameters["@id"].Value="CHBRWN";
Then I use another ExecuteReader call to fetch the result. It seems to work
OK, but my question is: Is it OK to reuse the parameter like this, or should
I delete and recreate it? Or should I be using two separate command objects?
Thanks.