Call a stored procedure with decimal parameter

  • Thread starter Thread starter Mona
  • Start date Start date
M

Mona

I have a stored procedure with a decimal parameter .

how can send the decimal value?
I try this but it gives an error , invalid cast specified.

Dim p1 As SqlParameter = .Parameters.Add("@EstConstructionCost_10",
System.Data.SqlDbType.Decimal, 9).Value = CDbl(txtEstConstructionCost.Text)

' Dim p1 As SqlParameter = .Parameters.Add("@EstConstructionCost_10",
System.Data.SqlDbType.Decimal).Value = 10

p1.Precision = 10

p1.Scale = 0
I appreciate any help
 
I've run into this a lot. The only successful way I've found to make it
work is to make the parameter a varchar; and use the SQL convert function in
the stored procedure.
 
the problem seems to be in statement
CDbl(txtEstConstructionCost.Text)

it should be CDbl(txtEstConstructionCost.Text.ToString())
or try
double.parse(txtEstConstructionCost.Text)

hope this helps
 
Back
Top