Click here to Skip to main content
15,868,016 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a value similar to '49102122011173902767-R' in a DataTable column. When am importing it into DB, it gets inserted as '49102122011173902767' from DataTable using C#.NET.

Anyone help me please.

Thanks in advance.
Posted
Updated 10-Sep-12 1:23am
v4
Comments
lukeer 10-Sep-12 7:25am    
Use the "Improve question" link to add the relevant part of your code. Surround your code with tags like those:
<pre lang="c#">YourCodeHere();<pre>
Mohamed Mitwalli 10-Sep-12 7:27am    
what is column data Type ?

Obviously, you'll get this problem. Because the datatype which you are using in your table's column is VARCHAR(20) and you are passing a value of length 22. That is why it is escaping last two chars of your string. Just increase the size of your column. i.e., from VARCHAR(20) to VARCHAR(25).


All the best.
--Amit
 
Share this answer
 
v2
Hi,

I you want to do from front end side then use substring. Remove last 2 characters and then save into DB.

http://www.dotnetperls.com/substring[^]

If you want to do from Back End then also you can use substring into your query.

http://msdn.microsoft.com/en-us/library/ms187748%28v=sql.90%29.aspx[^]

Thanks,
Viprat
 
Share this answer
 
You have given varchar(20) so it is taking only first 20 characters. Increase the column size to 50 and try to import.
 
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