FormView: Error inserting & updating currency

  • Thread starter Thread starter sck10
  • Start date Start date
S

sck10

Hello,

I have a SQL Server 2K table with a field set to currency. When I try to
insert or update a FormView, I get the following error:

Disallowed implicit conversion from data type nvarchar to data type money,
table 'tblCustomer_Revenue', column 'RevenueQtr01'. Use the CONVERT function
to run this query.

Any help with this would be appreciated.
 
The value you are trying to insert into the currency fields is text, probably
coming from a TextBox control or similar. Either way when you assign the
value to your parameter in the database use

Convert.ToDouble(MyString);

Which will return a value of type double from your string that represents
the currency amount. Make sure that you strip out any currency symbols
before conversion.
 
Hi Sck10,

Generally, if the datasource(DataSet, DataTable) bound to the FormView has
defined the column as the correct type(for your case, it's the decimal
type), the runtime should be able to automatically convert the input value
from string to the target type when performing inserting or updating. And
from the error info you provided, the problem seems that the Databound
control hasn't converted the value from string to the decimal type. Would
you provide some further info on the FormView's aspx template and what's
the datasource it bound to, are you using SqlDataSource control?

Regards,

Steven Cheng
Microsoft Online Community Support


==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================


This posting is provided "AS IS" with no warranties, and confers no rights.



Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
Back
Top