Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CONVERT Help 1

Status
Not open for further replies.

dvannoy

MIS
May 4, 2001
2,765
US
cmd.parameters.add(New OleDbParameter("@rate", txtRate.Text))

I am inserting records into my SQL 2000 server. in my SP I have converted the field to MONEY but the insert still fails.. I have tryed adding the CONVERT to the above code but cant seem to get it right.. I thought as long as the field was converted at the SP level that should be fine..

ANy help would be appreciated

Thanks

 
How about converting your string into a double?

double myRate = double.Parse (txtRate.Text);
cmd.parameters.add(New OleDbParameter("@rate", myRate));


HTH,

Keith
 
Did you set up the parameter type?

This is how I pass a money amount to a SQL Parameter.

cmd.Parameters.Add(New SqlParameter("@strMiles", SqlDbType.Decimal, (5)))
cmd.Parameters("@strMiles").Value = strMiles


Hope everyone is having a great day!

Thanks - Jennifer
 
I am using VB

Dim Rate As Double
Rate = Double.Parse(txtRate.Text)
cmd.parameters.add(New OleDbParameter("@rate", Rate))

I tryed this but got the below error message

"Input string was not in a correct format."



 
What backend are you using? If you are using SQL Server use the SQLParameter instead of the OleDbParameter.

Please notice in my example that I set the type of the parameter and then the value. I haven't used the OleDbParameter but I assume it has a similar function.

Hope everyone is having a great day!

Thanks - Jennifer
 
I also tryed

cmd.parameters.add(New OleDbParameter("@rate", txtRate.Text, OleDbType.Currency)

no luck

 
ok...got it..my problem was, I am formatting the currency texbox so the user can see a currency field before updating the DB..I guess I can just have the textbox formmated after the DB gets updated..

Thanks for your help

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top