Click here to Skip to main content
15,894,343 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
dr.read();
error is displaying like this in asp.net(C#)
(conversion failed when converting the nvarchar value to data type int)
how to rectify this one
Posted
Comments
nagendrathecoder 20-Mar-12 2:30am    
can you show us some more code? format of the data coming into datareader.
Dinesh Mani 20-Mar-12 2:32am    
Please provide more context... preceeding and succeding lines of code would help.

Dear Friend,

This error mainly occurs when you are trying to insert a nvarchar value into a data field of type int.

Check with your sql table that which fields are of type int and at the same time check from your code that you are entering correct entry into the field types.

This is a generalized error. Please follow the link for more explanation:-

162,000 results on conversion failed when converting the nvarchar value to data type int

Please don't forget to mark this as your answer if it helps you out.

Thanks
 
Share this answer
 
I thought u have nvarchar data in your table and int datatype on c# code page. this conversion is not allowed because there are some Alphabet. Make sure you dont have them.
 
Share this answer
 
Hi try this,

SQL
CAST(@your_param AS nvarchar(15))
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900