ÃHmed Élkady

ÃHmed Élkady

  • NA
  • 29
  • 2.4k

problem with checkbox and arabic when insert to sql server

Sep 4 2015 1:05 AM
i had a group of check boxes that insert the checked values in 1 row each time  by this code

SqlConnection sqlcon = new SqlConnection();
sqlcon.ConnectionString = @"Data Source=(local);Initial Catalog=cleopatra;Integrated Security=True";
List<string> checks = new List<string>();
foreach (Control cont in this.groupBox1.Controls)
{
if (cont is CheckBox)
{
if (((CheckBox)cont).Checked == true)
{
checks.Add(((CheckBox)cont).Text.ToString() + " , ");
}
}
}
sqlcon.Open();
SqlCommand sqlcmd = new SqlCommand("INSERT INTO pateint (mm) VALUES ( '" + string.Join(" ", checks) + "')", sqlcon);
sqlcmd.ExecuteNonQuery();
sqlcon.Close();
MessageBox.Show("ok");

and it insert as ???? marks i make it nchar and collation arabic

Answers (26)