c#向数据库中插入数据时出现乱码
mycomm.CommandText = "insert into student values('" + textBox1.Text + "','" + textBox2.Text
+ "','" + textBox3.Text + "','" + textBox4.Text + "'," +
textBox5.Text + ")";
myconn.Open();
int cmdresults = mycomm.ExecuteNonQuery();
myconn.Close();
if (cmdresults == 1)
{
textBox1.ReadOnly = true; textBox2.ReadOnly = true; textBox3.ReadOnly = true;
textBox4.ReadOnly = true; textBox5.ReadOnly = true;
button2.Enabled = true; button3.Enabled = true;
ListViewItem newitem = listView1.Items.Add(textBox1.Text);
newitem.SubItems.Add(textBox2.Text);
newitem.SubItems.Add(textBox3.Text);
newitem.SubItems.Add(textBox4.Text);
newitem.SubItems.Add(textBox5.Text);
button1.Text = "添加";
MessageBox.Show("插入数据库成功!");
}
else
MessageBox.Show("插入数据库失败");
c#向mysql数据库中插入中文数据时显示为乱码,跪求高手指点,感激不尽!
------解决方案--------------------试了,没用哦