Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
Hi need help................
 
We have an windows application developed in asp.net,C# and SQL server 2005.
 
We use our regional font (Tamil) to display in the application. The table in the database is set to nvarchar, so that it cud accept unicode character.
 
We have a textbox in the win form where its font set to tamil, when we type we cud see tamil letters in the textbox but if we we say textbox1.text and save to database it saves as english.
 
So my actual requirement is to get the textbox value (i.e tamil string) and store that tamil string to database (in db also it should stored as tamil). Frown | :( Frown | :(
 
please let me know if you are not clear on my question.....
Posted 16-Jun-11 1:56am

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Don't do it that way - it will confuse things, and leave you open to an SQL injection attack.
 
Instead, use a parametrized query - it isolates the Tamil from the SQL command and means it should just work:
Instead of:
SqlCommand cmd = new SqlCommand("INSERT INTO table VALUES ('" + textboxName.Text + "')", con);
Use
SqlCommand cmd = new SqlCommand("INSERT INTO table VALUES (@NAME)", con);
cmd.Parameters.AddWithVAlue(“@NAME”, textboxName.Text);
  Permalink  
Comments
senthilraj1983 at 17-Jun-11 7:39am
   
thats okay.. but if we say textboxname.text at run time we see english letters instead of tamil letters.... for eg... if i type "தமிழ்" in the textbox and when i say textboxname.text the string is "thamiz".. so i cant save as "தமிழ்" to the database.
Dhruval Dave at 31-Mar-14 9:57am
   
I am also facing the same thing. Does anyone have any possible solution ?

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



Advertise | Privacy | Mobile
Web01 | 2.8.1411022.1 | Last Updated 11 Aug 2011
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