Click here to Skip to main content
15,893,594 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
private void button1_Click(object sender, EventArgs e)
      {

      string constr = @"Data Source=GREATCOMPUTER\SQLSERVERS;Initial Catalog=test3;Integrated Security=True;Pooling=False";
          SqlConnection cn = new SqlConnection(constr);
          string str = "insert into tbl (Name) values(N'" + textBox1.Text + "')";
          SqlCommand cmd = new SqlCommand(str,cn);
          cn.Open();
          int i = cmd.ExecuteNonQuery();
          cn.Close();
          if (i != 0)
          {
              MessageBox.Show("Inserted.....");
          }


      }


What I have tried:

i need to insert Gujarati text in database but in that code only insert English word
if i insert "કોમલ" then it insert in database "komal" in this code
i use NVARCHAR in database column datatype and Gujarati saral 1 font in textbox font property
Posted
Updated 12-Apr-18 22:30pm
v2
Comments
Richard MacCutchan 12-Apr-18 7:16am    
Why are you calling Convert.ToString(textBox1.Text), on something that is already a string? Also do not use string concatenation in SQL commands. And finally have you checked that the actual values (not what is displayed on screen) are changed between insert and select?
Afzaal Ahmad Zeeshan 12-Apr-18 7:23am    
What is the data type of your column?
Kamariya Rahul 13-Apr-18 2:00am    
NVARCHAR
Richard MacCutchan 13-Apr-18 4:55am    
Show the code that converts it to English ...
Richard MacCutchan 13-Apr-18 6:58am    
Most unlikely.

1 solution

In addition to what Richard has said, also check your database column definition: if you are storing your data in a VARCHAR column, then it will be ASCII not UNICODE.

Also check the display code to ensure that the font selection is correct there: if you use a Western font, you are unlikely to get Gujarati characters displayed.
 
Share this answer
 
Comments
Kamariya Rahul 13-Apr-18 2:01am    
sir i already store data in NVARCHAR colunm and i use gujrati saral 1 font in textbox font property

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