Solved

Problem calling stored procedure with numeric/decimal data type

Posted on 2003-11-14
4
553 Views
Last Modified: 2012-08-13
  Ok, from chopping functionality out of my stored procedure, I've found where my ASP call to my stored procedure is messing up.  As it stands here is my stored procedure:

CREATE PROCEDURE sp_uscholar_studentinsert
@pid char(9),
@fname varchar(50),
@lname varchar(50),
@haddr varchar(100),
@hcity varchar(100),
@hstate char(2),
@hzip char(5),
@laddr varchar(100),
@lcity varchar(100),
@lstate char(2),
@lzip char(5),
@hscounty tinyint,
@hsstate char(2),
@hsname varchar(100),
@email varchar(100),
@semcredits smallint,
@totalcredits smallint,
@standing varchar(10),
@gpa numeric(3,2)
AS

if exists(Select * from uscholar_student where pid = @pid)
begin
update uscholar_student set
fname = @fname,
lname = @lname,
haddr = @haddr,
hcity = @hcity,
hstate = @hstate,
hzip = @hzip,
laddr = @laddr,
lcity = @lcity,
lstate = @lstate,
lzip = @lzip,
hscounty = @hscounty,
hsstate = @hsstate,
hsname = @hsname,
email = @email,
semcredits = @semcredits,
totalcredits = @totalcredits,
standing = @standing,
gpa = @gpa
where pid = @pid
end

else
return(1)

Go




The following is the relevant info from my ASP code (the second to last line is the one that doesn't work.  I know this because if I remove the gpa parameter and the gpa portion of the update statement, it works):

.
.
.
gpa = Request.Form("GPA")
.
.
.
set objCmd = Server.CreateObject("ADODB.Command")


objCmd.CommandText = "sp_uscholar_studentinsert"
set objCmd.ActiveConnection = Data3
objCmd.CommandType = adCmdStoredProc

objCmd.Parameters.Append objCmd.CreateParameter("@pid", adChar, adParamInput, 9, Session("pid"))
objCmd.Parameters.Append objCmd.CreateParameter("@fname", adVarChar, adParamInput, 50, fname)
objCmd.Parameters.Append objCmd.CreateParameter("@lname", adVarChar, adParamInput, 50, lname)
objCmd.Parameters.Append objCmd.CreateParameter("@haddr", adVarChar, adParamInput, 100, haddr)
objCmd.Parameters.Append objCmd.CreateParameter("@hcity", adVarChar, adParamInput, 100, hcity)
objCmd.Parameters.Append objCmd.CreateParameter("@hstate", adChar, adParamInput, 2, hstate)
objCmd.Parameters.Append objCmd.CreateParameter("@hzip", adChar, adParamInput, 5, hzip)
objCmd.Parameters.Append objCmd.CreateParameter("@laddr", adVarChar, adParamInput, 100, laddr)
objCmd.Parameters.Append objCmd.CreateParameter("@lcity", adVarChar, adParamInput, 100, lcity)
objCmd.Parameters.Append objCmd.CreateParameter("@lstate", adChar, adParamInput, 2, lstate)
objCmd.Parameters.Append objCmd.CreateParameter("@lzip", adChar, adParamInput, 5, lzip)
objCmd.Parameters.Append objCmd.CreateParameter("@hscounty", adTinyInt, adParamInput, , hscounty)
objCmd.Parameters.Append objCmd.CreateParameter("@hsstate", adChar, adParamInput, 2, hsstate)
objCmd.Parameters.Append objCmd.CreateParameter("@hsname", adVarChar, adParamInput, 100, hsname)
objCmd.Parameters.Append objCmd.CreateParameter("@email", adVarChar, adParamInput, 100, email)
objCmd.Parameters.Append objCmd.CreateParameter("@semcredits", adSmallInt, adParamInput, , semcredits)
objCmd.Parameters.Append objCmd.CreateParameter("@totalcredits", adSmallInt, adParamInput, , totalcredits)
objCmd.Parameters.Append objCmd.CreateParameter("@standing", adVarChar, adParamInput, 10 , standing)
objCmd.Parameters.Append objCmd.CreateParameter("@gpa", adNumeric, adParamInput, , gpa)


objCmd.Execute
0
Comment
Question by:mears11
  • 2
4 Comments
 
LVL 4

Expert Comment

by:af500
ID: 9749833
what's the error?
0
 
LVL 19

Expert Comment

by:Dexstar
ID: 9749854
mears11:

> The following is the relevant info from my ASP code (the second to last line
> is the one that doesn't work.  I know this because if I remove the gpa parameter
> and the gpa portion of the update statement, it works):

If you specify adDecimal or adNumeric data type, you must also set the NumericScale and the Precision properties of the Parameter object.

Hope That Helps,
Dex*
0
 
LVL 19

Accepted Solution

by:
Dexstar earned 250 total points
ID: 9749888
mears11:

> objCmd.Parameters.Append objCmd.CreateParameter("@gpa", adNumeric, adParamInput, , gpa)

Change that to this:
     Dim objParam
     Set objParam = objCmd.CreateParameter("@gpa", adNumeric, adParamInput, , gpa)
     objParam.Precision = 3
     objParam.NumericScale = 2
     objCmd.Parameters.Append objParam


Dex*
0
 

Author Comment

by:mears11
ID: 9749961
Thanks that was the trick!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now