C# .NET - Display and insert hindi text to sql server in a windows application

Asked By juhi sharma on 30-Mar-12 08:34 AM
Please help on the above matter,
I have a desktop application in which i have to save and retrieve hindi text data in to and from sql server,
Kindly help and better,if someone can provide a dumy example code related to problem...
Please help Its urjent.........  
dipa ahuja replied to juhi sharma on 30-Mar-12 09:02 AM

First make sure you have taken the dataType as nvarchar and also you have to implement the concept of Globalization and Localization:


► Globalization:
In Globalization, an application is developed to support various languages and cultures. Its features and code design independent of a single language or locale.

► Localization In Localization, an application is adapted for a local market. It may include translation of the UI to the local language and customizing its features if necessary. 


Here is one nice article you can see : 

http://www.c-sharpcorner.com/UploadFile/ankithakur/Globalization_Localization_in_DotNet_CSharp07032006023510AM/Globalization_Localization_in_DotNet_CSharp.aspx

Somesh Yadav replied to juhi sharma on 30-Mar-12 09:05 AM
Hi,

if you want to show the text in web application, then you need to do the same thing. Assing the same font for the html text box also.

But you cannot expect all the users to have the same font.

So, the best solution is to use Unicode fonts.

Check the below link. Using this tool you can get the Hindi text in Unicode.
http://www.google.com/transliterate/

If you are using the above unicode, then you can show the Hindi text in browsers and in your windows applications using the same format.
juhi sharma replied to dipa ahuja on 30-Mar-12 09:16 AM
Yes Dear,
 I had done this work already,I have created a table in sql server using nvarchar datatype in place of varchar and using above insert statement there are only two columns in my application(station and vehiclename ) having hindi text text value..
          string sql = "insert into JourneyDetailsOfAvehocle(Date,Station,VehicleName,TotalKM,Totaljourneycost,AdvanceAmount,ToleAndParkingAmount,DueAmount) values('" + dateTimePicker1.Text + "',N'" + textBox2.Text + "',N'" + textBox3.Text + "',N'"+textBox4.Text+"','"+textBox5.Text+"','"+textBox6.Text+"','"+textBox7.Text+"','"+textBox8.Text+"')";

Kindly look into the line and help me with a dumy example code(if possible)
regards
Juhi

juhi sharma replied to Somesh Yadav on 30-Mar-12 09:22 AM
No Dear,
Im not working with web application,Im am working with a desktop application...
kalpana aparnathi replied to juhi sharma on 30-Mar-12 09:34 AM
hi,

You need to convert unicode to hindi devnagari using regular expression and then it store to the sql server.


string i = "yourinput";
Regex rx = new Regex(@"([0-9A-Fa-f]{4});");
string output = rx.Replace(i, match => ((char)Int32.Parse(match.Groups[1].Value, NumberStyles.HexNumber)).ToString());

And pass it to the database through the dataset

Regards,
anita kumari replied to juhi sharma on 28-Oct-13 06:07 AM
end of post
anita kumari replied to juhi sharma on 28-Oct-13 06:08 AM
end of post