|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
asp and passing parameters to SQL stored procedure
Hi, I have a problem with input parameter which has Decimal DataType. Stored procedure doesn't work. In table QTY is decimal(5).
Please, suggest what's wrong with this: cmd.Parameters.Append(cmd.CreateParameter("qty", adDecimal, adParamInput, 5, newqty)) Thanks in advance. |
|
#2
|
||||
|
||||
|
Are you getting an error?
Post the stored procedure code and the ASP code. |
|
#3
|
|||
|
|||
|
It's very simple insert. I can insert everything but recgty.
Code:
CREATE PROCEDURE ms_updatitems @mkey int, @jobno varchar(20), @pono int, @recqty decimal(5), @revdat datetime, @recdat datetime, @comment varchar(400), @docmtr bit AS INSERT TABLE1 (mkey, jobno, pono, recivqty, revisdate, recivdate, comment, docmtr) VALUES(@mkey, @jobno, @pono, @recqty, @revdat, @recdat, @comment, @docmtr) GO When I commented recgty parameter it worked Code:
Set cmd = Server.CreateObject("ADODB.Command")
cmd.ActiveConnection = Conn
cmd.CommandType = adCmdStoredProc
cmd.CommandText = "ms_updatitems1"
cmd.Parameters.Append(cmd.CreateParameter("mkey", adInteger, adParamInput, 4, Str1))
cmd.Parameters.Append(cmd.CreateParameter("jobno", adVarChar, adParamInput, 20, Session("MSJobNumber")))
cmd.Parameters.Append(cmd.CreateParameter("pono", adSmallInt, adParamInput, 2, Str2))
cmd.Parameters.Append(cmd.CreateParameter("recqty", adDecimal, adParamInput, 5, Str4))
cmd.Parameters.Append(cmd.CreateParameter("revdat", adDBTimeStamp, adParamInput, 8, Str3))
cmd.Parameters.Append(cmd.CreateParameter("recdat", adDBTimeStamp, adParamInput, 8, Str5))
cmd.Parameters.Append(cmd.CreateParameter("comment", adVarChar, adParamInput, 400, Str6))
cmd.Parameters.Append(cmd.CreateParameter("docmtr", adTinyInt, adParamInput, 1, Str7))
On Error Resume Next
cmd.Execute()
Last edited by Memnoch : March 9th, 2005 at 04:13 PM. |
|
#4
|
||||
|
||||
|
Is there an error?
|
|
#5
|
|||
|
|||
|
Yes, it's an error. I don't know how to catch exact error message from stored procedure within asp code. I just use:
On Error Resume Next cmd.execute() If Err <> 0 then Response.Write "something" |
|
#6
|
||||
|
||||
|
1) Comment out the On Error Resume Next code.
2) Try this Code:
cmd.execute()
If Err <> 0 then
Response.Write("Error: " & Err.Description)
|
|
#7
|
|||
|
|||
|
It gave me: The precision is invalid.
In design table recqty has precision 8, scale 3 and length 5. What value do I have to assign to input parameter? |
|
#8
|
||||
|
||||
|
try adding
Code:
cmd.Parameters("recqty").Precision = 8
cmd.Parameters("recqty").Scale = 3
|
|
#9
|
|||
|
|||
|
Memnoch, thank you!!!!!
It works. cmd.Parameters("recqty").Precision = 8 is enough. It gave me an error that object doesn't support property Scale. Thanks again. |
|
#10
|
||||
|
||||
|
Read my signature above about "Helpful Posts" and adding to a users reputation.
Glad it works for you. |
![]() |
| Viewing: ASP Free Forums > Database > Microsoft SQL Server > asp and passing parameters to SQL stored procedure |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|