Call a stored procedure with decimal parameter

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
 
S

Steve Miller

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.
 
R

Rajesh Tiwari

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top