Decimal data type precision from data reader and sql command

newdbo

Active member
Joined
Aug 23, 2009
Messages
25
Programming Experience
Beginner
Hi all, i really need help. I exported xlxs files to sql server using oledb data reader. I'm using visual studio 2005.
This is my code :
VB.NET:
Dim costbln1 As decimal = 0 (how to declare the data type to get precision like 999,9999)
.
.
.
.
VB.NET:
If Not oledbdr.IsDBNull(39) Then
costbln1 = Decimal.Parse(oledbdr.GetValue(39))
Else
costbln1 = 0.0
End If
.
.
.
VB.NET:
sqlcmd1.Parameters.Add("@CostBln1", SqlDbType.Decimal, 9).Value = costbln1 --> how to declare that this parameter will have precision just like i mentioned above (999,9999)


Thanks in advance
 
The precision of the .NET Decimal data type is not variable. As for SqlParameters, you've already got the code to create one. You then simply set its Scale and Precision properties:
VB.NET:
With sqlcmd1.Parameters.Add("@CostBln1", SqlDbType.Decimal, 9)
    .Precision = 7
    .Scale = 4
    .Value = costbln1
End With
 

Latest posts

Back
Top