Ask a Question related to ASP Database, Design and Development.
-
sean #1
Executing Stored Procedure in loop duplicates row content
Hi,
I am executing a stored procedure from a form post, when I execute the
stored procedure it inserts a row for every checkbox checked, however it is
populating the rows with the same content. It will only give the values from
the first form object and insert the same to content to the value of "i".
How can I make this insert the correct content into my DB?
Thanks in advance for your answer
Sean
Set adoCmd = Server.CreateObject("ADODB.Command")
adoCmd.ActiveConnection = db_conn
adoCmd.CommandType = adCmdStoredProc
adoCmd.CommandText = "sp_InsertOptions"
for i = 1 to Request("chkOptions").count
strOption = Request("chkOptions")(i)
adoCmd.Parameters.Append
adoCmd.CreateParameter("pProductID",adInteger)
adoCmd.Parameters("pProductID") = ProductID
adoCmd.Parameters.Append
adoCmd.CreateParameter("pOptionValue",adVarChar ,adParamInputOutput,255)
adoCmd.Parameters("pOptionValue") = Request("chkOptions")(i)
adoCmd.Execute()
next
sean Guest
-
Error while executing stored procedure
I get the following error message when I am trying to execute a stored procedure. It runs fine on my dev server but giving error in production. ... -
problems executing wscript_command stored procedure
I'm trying to call the wscript_command stored procedure and use the ID of a DTS job as one of the input parameters. I am getting the message "Error... -
Executing a procedure from the cammand line
I have a SQL command procedure, myproc.sql, containing sql statements. After I login to MySQL, how do I execute this procedure? mysql> ??????... -
DBD::Oracle not executing stored procedure properly...
Hamish Whittal wrote: is this what you have in your code: "$$dbh->prepare($sql)"? david -
#22403 [Com]: PHP crashes when executing a sql procedure without parameters
ID: 22403 Comment by: daniel dot beet at accuratesoftware dot com Reported By: cesararnold at yahoo dot com dot br... -
Bob Barrows #2
Re: Executing Stored Procedure in loop duplicates row content
It's time for some debugging. See below:
sean wrote:You should avoid using "sp_" to prefix your stored procedure names. "sp_"> Hi,
>
> I am executing a stored procedure from a form post, when I execute the
> stored procedure it inserts a row for every checkbox checked, however
> it is populating the rows with the same content. It will only give
> the values from the first form object and insert the same to content
> to the value of "i". How can I make this insert the correct content
> into my DB?
>
> Thanks in advance for your answer
>
> Sean
>
>
>
> Set adoCmd = Server.CreateObject("ADODB.Command")
> adoCmd.ActiveConnection = db_conn
> adoCmd.CommandType = adCmdStoredProc
> adoCmd.CommandText = "sp_InsertOptions"
should be reserved for system stored procedures. You pay a performance
penalty by using this prefix for you user-defined procedures since SQL will
try to execute it as if it's a system procedure.
This should be:>
> for i = 1 to Request("chkOptions").count
for i = 1 to Request.Form("chkOptions").count
Response.write "Request.Form(""chkOptions"")(" & i & ")"> strOption = Request("chkOptions")(i)
Response.write " contains " & strOption & "<BR>"
Why not use strOption?> adoCmd.Parameters.Append
> adoCmd.CreateParameter("pProductID",adInteger)
> adoCmd.Parameters("pProductID") = ProductID
> adoCmd.Parameters.Append
> adoCmd.CreateParameter("pOptionValue",adVarChar
> ,adParamInputOutput,255)
> adoCmd.Parameters("pOptionValue") =Request.Form("chkOptions")(i)
adoCmd.Parameters("pOptionValue") =strOption
If your debugging indicates that the loop is correctly setting the value of> adoCmd.Execute()
> next
the strOption variable, then you may need to set the Command object's
Prepared property to True.
HTH,
Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Bob Barrows Guest
-
Keith #3
Executing Stored Procedure in loop duplicates row content
Not sure if this will help, but try deleting your existing
parameters after you execute.
I execute the>-----Original Message-----
>Hi,
>
>I am executing a stored procedure from a form post, whenchecked, however it is>stored procedure it inserts a row for every checkboxgive the values from>populating the rows with the same content. It will onlythe value of "i".>the first form object and insert the same to content to("pOptionValue",adVarChar ,adParamInputOutput,255)>How can I make this insert the correct content into my DB?
>
>Thanks in advance for your answer
>
>Sean
>
>
>
> Set adoCmd = Server.CreateObject("ADODB.Command")
>adoCmd.ActiveConnection = db_conn
>adoCmd.CommandType = adCmdStoredProc
>adoCmd.CommandText = "sp_InsertOptions"
>
>for i = 1 to Request("chkOptions").count
> strOption = Request("chkOptions")(i)
> adoCmd.Parameters.Append
>adoCmd.CreateParameter("pProductID",adInteger)
> adoCmd.Parameters("pProductID") = ProductID
> adoCmd.Parameters.Append
>adoCmd.CreateParameter("chkOptions")(i)> adoCmd.Parameters("pOptionValue") = Request'' verify syntax for this> adoCmd.Execute()
for each p in adoCmd.Parameters
adoCmd.Parameters(p).delete
next
>next
>
>
>.
>Keith Guest



Reply With Quote

