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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert to Currency

Status
Not open for further replies.

dvannoy

MIS
May 4, 2001
2,765
US
This is something I cant figure out so I thought I would post it here to try and get an answer.

ASP.NET. I am doing a simple INSERT Statement into a SQL Table. 2 Fields are MONEY. I convert the textboxes using

TextBox.Text = FormatCurrency(TextBox.Text)

When trying to INSERT the records into the table I get an error saying to Convert varchr to currency. I cant figure out why?? if the textbox is already formatted as currency I think SQL should already accept it correct??

Any help would be appreciated

Thanks


 
Without seeing the SQL code. I guess you are trying to construct a SQL statement by dropping the variable that; s stores as a curreny data type into a SQL string

You can only concatenate string varaiables, you can't concatenate a curreny data type with a string data type.

i.e.

sting + string = string

string + curreny will not make a SQL string
 
The textbox is formatted as Currency type. the field on the SQL server is set to Money.

INSERT INTO Table (MoneyField) VALUES ( '" & txtUnitPrice.Text & "')

I have tryed to use the CONVERT Function within the INSERT statement and that wont work either.

 
if the textbox is already formatted as currency I think SQL should already accept it correct??

Not necessarily....what does CURRENCY accept?

Money only accepts upto 4 decimal places (123.1234). Could your value as CURRENCY have too many decimal places?

-SQLBill
 
Also, does CURRENCY allow COMMAs (,)? MONEY does not allow commas.

-SQLBill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top