Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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). :( :(

please let me know if you are not clear on my question.....
Posted

1 solution

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);
 
Share this answer
 
Comments
senthilraj1983 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 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)



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