I am having a function which accepts Database parameter array, and it
inserts to the database inside a loop.

Note:

inside the loop i am changing the values of the parameter array .

it works fine if the loop executes for only one time, but if the loop
executes more than one time i am getting the error : "field xyz is already
contained by another SqlParameterCollection"



Function abc(Parameter_Array)

begin loop

alter Parameter_Array' values

Create command object

Add parameters to the command object //i am getting
error at this point,if this is executed for the second time .

Execute

command.parameters.close();

set connection,command etc.. to null

end

Re: SQL Parameter bug by Cor

Cor
Mon Jul 17 01:46:59 CDT 2006

Prabeep,

You have to create the parametercollection once with add, than you have to
set the values of those.

http://msdn2.microsoft.com/en-us/library/system.data.sqlclient.sqlparameter.value.aspx

I hope this helps,

Cor

"Pradeep" <Pradeep@discussions.microsoft.com> schreef in bericht
news:CD2DC26B-A711-4AEA-82AA-3C0BDF4E973F@microsoft.com...
>
>
> I am having a function which accepts Database parameter array, and it
> inserts to the database inside a loop.
>
> Note:
>
> inside the loop i am changing the values of the parameter array .
>
> it works fine if the loop executes for only one time, but if the loop
> executes more than one time i am getting the error : "field xyz is already
> contained by another SqlParameterCollection"
>
>
>
> Function abc(Parameter_Array)
>
> begin loop
>
> alter Parameter_Array' values
>
> Create command object
>
> Add parameters to the command object //i am getting
> error at this point,if this is executed for the second time .
>
> Execute
>
> command.parameters.close();
>
> set connection,command etc.. to null
>
> end
>
>
>
>
>
>



Re: SQL Parameter bug by Cor

Cor
Mon Jul 17 01:57:02 CDT 2006

Prabeep,

Please don't put Bug in your subject when it is a bug in your program, this
makes the attention from Microsoft guys much lower for this.

Thanks in advance

Cor

"Pradeep" <Pradeep@discussions.microsoft.com> schreef in bericht
news:CD2DC26B-A711-4AEA-82AA-3C0BDF4E973F@microsoft.com...
>
>
> I am having a function which accepts Database parameter array, and it
> inserts to the database inside a loop.
>
> Note:
>
> inside the loop i am changing the values of the parameter array .
>
> it works fine if the loop executes for only one time, but if the loop
> executes more than one time i am getting the error : "field xyz is already
> contained by another SqlParameterCollection"
>
>
>
> Function abc(Parameter_Array)
>
> begin loop
>
> alter Parameter_Array' values
>
> Create command object
>
> Add parameters to the command object //i am getting
> error at this point,if this is executed for the second time .
>
> Execute
>
> command.parameters.close();
>
> set connection,command etc.. to null
>
> end
>
>
>
>
>
>



Re: SQL Parameter bug by Robert

Robert
Mon Jul 17 10:52:26 CDT 2006

"Cor Ligthert [MVP]" <notmyfirstname@planet.nl> wrote in message
news:%23MylI4WqGHA.3908@TK2MSFTNGP05.phx.gbl...
> Prabeep,
>
> Please don't put Bug in your subject when it is a bug in your program,
> this makes the attention from Microsoft guys much lower for this.

Actually, that's a catch-22. He didn't know it was a bug in his program
until he posted here.

A better, more general rule should be "When asking for help from the
community, don't draw conclusions in your subject line" :)

Robert


Re: SQL Parameter bug by Marina

Marina
Mon Jul 17 12:55:37 CDT 2006

That is true. But who is more likely to have a bug: Microsoft or him?

It's a bit presumptuous to think that it isn't you who is doing something
right, but that it is Microsoft.

"Robert Simpson" <rsimpson@noemail.noemail> wrote in message
news:O5sSbjbqGHA.4508@TK2MSFTNGP04.phx.gbl...
> "Cor Ligthert [MVP]" <notmyfirstname@planet.nl> wrote in message
> news:%23MylI4WqGHA.3908@TK2MSFTNGP05.phx.gbl...
>> Prabeep,
>>
>> Please don't put Bug in your subject when it is a bug in your program,
>> this makes the attention from Microsoft guys much lower for this.
>
> Actually, that's a catch-22. He didn't know it was a bug in his program
> until he posted here.
>
> A better, more general rule should be "When asking for help from the
> community, don't draw conclusions in your subject line" :)
>
> Robert
>