title: C#.Net Windows Application Hindi Writing and display
body: <p>I am working on a windows form application project using VS 2008 Express with C# in which both hindi and english data needs to be stored in SQL Server 2008 Express database.</p>
  
  <p>I have created a table with <code>NVARCAR(MAX)</code> columns and used the following code for storing hindi into database:</p>
  
  <pre><code>com.CommandText = "INSERT INTO test(name, data) VALUES (@a, @b)";
  com.Parameters.Add("@a", SqlDbType.NVarChar).Value =  textBox1.Text.Trim();
  com.Parameters.Add("@b", SqlDbType.NVarChar).Value =  textBox2.Text.Trim();
  
  con.Open();
  
  if (com.ExecuteNonQuery() &gt; 0)
      MessageBox.Show("Success");
  else
      MessageBox.Show("Failed");
  
  con.Close();
  </code></pre>
  
  <p>The code works perfectly fine, and saves data in hindi. </p>
  
  <p>Now following is the problem I am facing:</p>
  
  <ol>
  <li><p>When retrieving, I see question marks instead of hindi characters in datagridview and label. I need to show hindi as a result of select query. This is the code that I am using:</p>
  
  <pre><code>com.CommandText = "SELECT data FROM test WHERE name=@name";
  com.Parameters.Add("@name", SqlDbType.NVarChar).Value = textBox1.Text.Trim();
  
  con.Open();
  
  SqlDataAdapter da = new SqlDataAdapter(com);
  
  DataTable dt = new DataTable();
  da.Fill(dt);
  
  dataGridView1.DataSource = dt;
  
  SqlDataReader dr = com.ExecuteReader();
  
  if(dr.HasRows)
  {
      while(dr.Read())
      {
          textBox2.Text = dr.GetValue(0).ToString();
      }
  }
  
  con.Close();
  </code></pre>
  
  <p>NOTE: Hindi comparison works fine but hindi is not displayed in datagridview and label/textbox.</p>
  
  <p>NOTE: I'm using Windows 7 that may not have hindi installed. Also, I cannot install hindi regional language because it demands licensed windows and I cannot be sure that every machine will have a licensed version.</p></li>
  <li><p>Also, the mentioned code works fine on copy-pasted hindi. I cannot type in hindi while inserting data.</p></li>
  </ol>
  
  <p>Kindly Help.</p>