在表单中输入阿拉伯语后,我按下插入按钮将字段插入到数据库中。但是字符会变成奇怪的问号,例如:"?????"
。数字或英文字符不会发生这种情况。
如何键入阿拉伯语并在数据库中仍然将其作为阿拉伯语,而不是作为"?????"
?
这是一些代码
SqlConnection cn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["StoreConnectionString"].ToString());
public AddBook()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string X;
cn.Open();
SqlCommand cm = new SqlCommand("SELECT COUNT(*) FROM StoreItem", cn);
Int32 count = (Int32)cm.ExecuteScalar();
X = count.ToString();
cn.Close();
SqlCommand cmd = new SqlCommand("insert into StoreItem (ID, Title, Writer, Price, Qun, Date) Values ('" + X + "','" + textBox1.Text + "', '" + textBox2.Text + "', '" + textBox3.Text + "', '" + textBox4.Text + "', '" + DateTime.Now.ToString("d/M/yyyy") + "')", cn);
cn.Open();
cmd.ExecuteNonQuery();
cn.Close();
textBox1.Text = null;
textBox2.Text = null;
textBox3.Text = null;
textBox4.Text = null;
this.Close();
}
private void button2_Click(object sender, EventArgs e)
{
this.Close();
}
和
private void Rsh()
{
SqlDataAdapter ADAP = new SqlDataAdapter("Select * FROM StoreItem", cn);
DataSet DS = new DataSet();
ADAP.Fill(DS, "Store");
dataGridView1.DataSource = DS.Tables["Store"];
dataGridView1.Columns[1].Width = 200;
dataGridView1.Columns[0].HeaderCell.Value = "#";
dataGridView1.Columns[1].HeaderCell.Value = "عنوان الكتاب";
dataGridView1.Columns[2].HeaderCell.Value = "الكاتب";
dataGridView1.Columns[3].HeaderCell.Value = "السعر";
dataGridView1.Columns[4].HeaderCell.Value = "الكمية";
dataGridView1.Columns[5].HeaderCell.Value = "تاريخ دخول";
}