Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 Other Development Tools
 Passing numeric data to stored procedure

Author  Topic 

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2006-05-11 : 22:27:13
hello,
i have been having this problem with passing numeric data to a stored procedure.

my script edit is here

sms_credits.Parameters.Append sms_credits.CreateParameter("@cost_4", 131, 1,8,sms_credits__cost_4)


131 stands for numeric data, and 8 stands for the length, how do i add a precision of 2 to it ???

Am getting the error

[
Microsoft OLE DB Provider for ODBC Drivers error '80040e21' 

[Microsoft][ODBC SQL Server Driver]Invalid scale value

/welcome/welcome/messages/sms_credits_transfer_sp.asp, line 36




Any advice on this ?

Thanks
afrika

uberman
Posting Yak Master

159 Posts

Posted - 2006-05-12 : 04:27:53
.parameters.append .createParameter("@duration", adDecimal, adParamInput,,somevalue)
.parameters("@duration").precision = --your value here
.parameters("@duration").numericscale = --your value here
Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2006-05-12 : 17:25:05
thanks a lot uberman, this is what it translates to, but i still get some errors


sms_credits.Parameters.Append sms_credits.CreateParameter("@credits_1", 131, 1,8,sms_credits__credits_1)
sms_credits.parameters("@credits_1").precision = 4
sms_credits.parameters("@credits_1").numericscale = 1


error message is

quote:

ADODB.Command error '800a0d5d'

Application uses a value of the wrong type for the current operation.

/welcome/welcome/messages/sms_credits_transfer_sp.asp, line 32




line 32 is the first line

another error message i get is

quote:
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[Microsoft][ODBC SQL Server Driver][SQL Server]168.00

/welcome/welcome/messages/sms_credits_transfer_sp.asp, line 40
Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2006-05-13 : 00:12:05
I Finally got it to work, I pass my parameters as varchar and it works just fine.

i commented out the precise and scale values. However i woudl have to read up more on this, thanks for your advice

Afrika


sms_credits.Parameters.Append sms_credits.CreateParameter("@credits_1", 200, 1,20,sms_credits__credits_1)
'sms_credits.parameters("@credits_1").precision = 4
'sms_credits.parameters("@credits_1").numericscale = 1
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2006-05-13 : 03:14:00
Personally I would never use a parameter like "200" instead of something readable like "adDecimal" or "adVarChar"

Kristen
Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2006-05-13 : 04:36:46
Well very true.

I guess over the years i drifted to using numeric parameters.

Once again, point(s) NOTED !!!
Afrika
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2006-05-13 : 04:54:51
Well if you know what they are that's fine, but still a bit open to mis-typing. However, they are unlikely to be so obvious to someone else looking at your code!

Kristen
Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2006-05-13 : 11:52:56
Ok no problem,
i use code snippets, which have been tested and ok.
Go to Top of Page
   

- Advertisement -