|
-
Mar 28th, 2008, 03:23 PM
#1
Thread Starter
PowerPoster
[RESOLVED] Get decimal data type in stored proc and return to VB.NET
I am struggling a little bit with getting a decimal datatype back from my stored procedure.
In my table, I have columns whose datatype is decimal 9 (18,4). I have a stored procedure that gets a row from that table, and I have a parameter for the decimal column defined as:
@mid AS decimal(18,4) OUTPUT
Is that correct? First I had it as decimal(9) but I wasn't sure I was getting it back correctly.
Then in my vb code, is this correct?
Code:
Dim p12 As New SqlParameter()
p12.ParameterName = "@mid"
p12.SqlDbType = SqlDbType.Decimal
p12.Direction = ParameterDirection.Output
command.Parameters.Add(p12)
conn.Open()
command.ExecuteNonQuery()
mid = CDec(p12.Value)
In the debugger, if I look at p12.Value it says 10D. The value is something more like 10.1356. Am I doing something wrong or is it the debugger's way of displaying it and how do I get the precision I want?
Thanks.
-
Mar 28th, 2008, 03:39 PM
#2
Re: Get decimal data type in stored proc and return to VB.NET
look to see if there is a Precision (set it to 18) and a NumericScale (set to 4) on the parameter object and set them before adding it to the colleciton.
-tg
-
Mar 31st, 2008, 03:10 PM
#3
Thread Starter
PowerPoster
Re: Get decimal data type in stored proc and return to VB.NET
Thank you for the reply, techgnome.
For various reasons I changed my stored procedure to return a row rather than a parameter and it seemed easier to get the decimal value that way also. They are coming back to my program and going in my grid just as I want them!
Have a nice day and thanks for taking the time to help out.
Marlene
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|