Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseMicrosoft SQL Server

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old March 9th, 2005, 10:45 AM
Natasha Natasha is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 27 Natasha User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 h 31 m 2 sec
Reputation Power: 0
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.

Reply With Quote
  #2  
Old March 9th, 2005, 12:01 PM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
ASP Free God 14th Plane (11500 - 11999 posts)
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,776 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 8 h 27 m 42 sec
Reputation Power: 470
Are you getting an error?
Post the stored procedure code and the ASP code.

Reply With Quote
  #3  
Old March 9th, 2005, 01:28 PM
Natasha Natasha is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 27 Natasha User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 h 31 m 2 sec
Reputation Power: 0
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.

Reply With Quote
  #4  
Old March 9th, 2005, 01:50 PM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
ASP Free God 14th Plane (11500 - 11999 posts)
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,776 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 8 h 27 m 42 sec
Reputation Power: 470
Is there an error?

Reply With Quote
  #5  
Old March 9th, 2005, 02:28 PM
Natasha Natasha is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 27 Natasha User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 h 31 m 2 sec
Reputation Power: 0
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"

Reply With Quote
  #6  
Old March 9th, 2005, 04:15 PM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
ASP Free God 14th Plane (11500 - 11999 posts)
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,776 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 8 h 27 m 42 sec
Reputation Power: 470
1) Comment out the On Error Resume Next code.

2) Try this
Code:
cmd.execute()

If Err <> 0 then
Response.Write("Error: " & Err.Description)

Reply With Quote
  #7  
Old March 9th, 2005, 06:14 PM
Natasha Natasha is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 27 Natasha User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 h 31 m 2 sec
Reputation Power: 0
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?

Reply With Quote
  #8  
Old March 9th, 2005, 07:11 PM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
ASP Free God 14th Plane (11500 - 11999 posts)
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,776 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 8 h 27 m 42 sec
Reputation Power: 470
try adding
Code:
cmd.Parameters("recqty").Precision = 8 
cmd.Parameters("recqty").Scale = 3 

Reply With Quote
  #9  
Old March 10th, 2005, 09:00 AM
Natasha Natasha is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 27 Natasha User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 h 31 m 2 sec
Reputation Power: 0
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.

Reply With Quote
  #10  
Old March 10th, 2005, 09:07 AM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
ASP Free God 14th Plane (11500 - 11999 posts)
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,776 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 8 h 27 m 42 sec
Reputation Power: 470
Read my signature above about "Helpful Posts" and adding to a users reputation.

Glad it works for you.

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft SQL Server > asp and passing parameters to SQL stored procedure


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT