FormView: Error inserting & updating currency

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

Guest

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

Steven Cheng[MSFT]

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

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

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top