Showing posts with label parameters. Show all posts
Showing posts with label parameters. Show all posts

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.

Friday, March 9, 2012

removing parameters

I created a report and gave a column a parameter in the data definition.
When I do a preview it gives a textbox to enter the parameter. Works fine.
I don't like the name of the parameter and change it in the data definition.
Now when I do a preview, I get two textboxes for parameters, one for the old
name and one for the new name. I only have one parameter, but it is showing
two prompts. How do I get rid of the textbox prompt for the old one?
Thanks,
Leon.You remove the "display" parameters in the Report, Report Parameters dialog.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Leon Chuck Gosslin" <powerb@.inel.gov> wrote in message news:OOlU0fHhEHA.3520@.TK2MSFTNGP10.phx.gbl...
> I created a report and gave a column a parameter in the data definition.
> When I do a preview it gives a textbox to enter the parameter. Works fine.
> I don't like the name of the parameter and change it in the data definition.
> Now when I do a preview, I get two textboxes for parameters, one for the old
> name and one for the new name. I only have one parameter, but it is showing
> two prompts. How do I get rid of the textbox prompt for the old one?
> Thanks,
> Leon.
>