Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#3.0 ASP.NET
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 19-Mar-12 21:20pm
Comments
nagendrathecoder at 20-Mar-12 2:30am
   
can you show us some more code? format of the data coming into datareader.
Dinesh Mani at 20-Mar-12 2:32am
   
Please provide more context... preceeding and succeding lines of code would help.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Hi try this,
 
CAST(@your_param AS nvarchar(15))
  Permalink  

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



Advertise | Privacy | Mobile
Web02 | 2.8.1411022.1 | Last Updated 11 May 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100