Monday, March 12, 2012

Removing SQL Parameters from Command Object after use.

Hi all,

is it good practice to remove SQL Parameters from the Command Object's parameters collection after the CommandObject has executed its SQL containing the SQL Parameters?

The reason I ask is because I have encountered some issues (errors) stating that the SQL Parameter cant be used because it is still contained in another Parameter collection - ( I created the Parameters, and then use these same parameter (through looping) to execute new commands).

Thanks

Tryst, if you are in a loop reusing the same command object, clear your parameters either before you begin adding them again, or after you execute the command using:

cmd.Parameters.Clear

That should be all you need to reuse your parameter objects again.

|||OK - thanks.

No comments:

Post a Comment