代码如下:
private void button1_Click(object sender, EventArgs e)
{
AddRd();
this.Hide();
Manager mm = new Manager();
mm.Show();
} private void AddRd()
{
using (SqlConnection conn = new SqlConnection(@"Data Source=(local);Initial Catalog = LibrarySystem;User ID=sa ;pwd=123456"))
{
using (SqlCommand cmd = new SqlCommand("insert into Reader(rdID,rdName,rdSex,rdType,rdDept,rdPhone,rdEmail) values ('"+textBox7.Text+"','" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" +textBox4.Text + "','" + textBox5.Text + "','" + textBox6.Text + "')", conn))
{
cmd.Connection.Open();
cmd.ExecuteNonQuery();
cmd.Connection.Close();
}
}
调用ExecuteNonQuery以后只有datagridview里面修改了结果,但是数据库没有修改,请各位教我!~
private void button1_Click(object sender, EventArgs e)
{
AddRd();
this.Hide();
Manager mm = new Manager();
mm.Show();
} private void AddRd()
{
using (SqlConnection conn = new SqlConnection(@"Data Source=(local);Initial Catalog = LibrarySystem;User ID=sa ;pwd=123456"))
{
using (SqlCommand cmd = new SqlCommand("insert into Reader(rdID,rdName,rdSex,rdType,rdDept,rdPhone,rdEmail) values ('"+textBox7.Text+"','" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" +textBox4.Text + "','" + textBox5.Text + "','" + textBox6.Text + "')", conn))
{
cmd.Connection.Open();
cmd.ExecuteNonQuery();
cmd.Connection.Close();
}
}
调用ExecuteNonQuery以后只有datagridview里面修改了结果,但是数据库没有修改,请各位教我!~
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货