|  | 
 
| 
RT 错误信息如下:
x
马上注册,结交更多好友,享用更多功能^_^您需要 登录 才可以下载或查看,没有账号?立即注册  
 
 违反了 PRIMARY KEY 约束 'PK_ruku_1'。不能在对象 'dbo.ruku_1' 中插入重复键。
 语句已终止。
 
 
 源码:
 private void tushuxiugai_Load(object sender, EventArgs e)
 {
 // TODO: 这行代码将数据加载到表“yonghu1DataSet2.ruku_1”中。您可以根据需要移动或删除它。
 this.ruku_1TableAdapter.Fill(this.yonghu1DataSet2.ruku_1);
 
 }
 
 private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
 {
 int index = this.dataGridView1.CurrentCell.RowIndex;
 this.textBox1.Text = this.dataGridView1.Rows[index].Cells[0].Value.ToString();
 this.textBox2.Text = this.dataGridView1.Rows[index].Cells[1].Value.ToString();
 this.textBox3.Text = this.dataGridView1.Rows[index].Cells[2].Value.ToString();
 this.textBox4.Text = this.dataGridView1.Rows[index].Cells[3].Value.ToString();
 this.textBox5.Text = this.dataGridView1.Rows[index].Cells[4].Value.ToString();
 }
 
 private void button1_Click(object sender, EventArgs e)
 {
 lianjiecs conn = new lianjiecs();
 SqlConnection myconn = conn.GetConnection();
 SqlCommand mycomm = myconn.CreateCommand();
 myconn.Open();
 if (textBox1.Text == "" && textBox2.Text == "" && textBox3.Text == "" && textBox4.Text == "" && textBox5.Text == "")
 {
 MessageBox.Show("修改信息不能为空!");
 }
 else
 {
 mycomm.CommandText = "update ruku_1 set bianhao='" + textBox1.Text + "', shuming = '" + textBox2.Text + "',zuozhe = '" + textBox3.Text + "',rikushujian ='" + textBox4.Text + "',jiage='" + textBox5.Text + "'";
 mycomm.ExecuteNonQuery();
 mycomm.Dispose();
 myconn.Close();
 MessageBox.Show("更改成功!");
 textBox5.Text = "";
 textBox4.Text = "";
 textBox3.Text = "";
 textBox2.Text = "";
 textBox1.Text = "";
 }
 
 }
 
 
 
 
 private void button2_Click(object sender, EventArgs e)
 {
 this.Close();
 main a = new main();
 a.Show();
 }
 
 数据库信息:
 
   
 
 求解 这种问题该怎么解决。。。
 还有如果需要添加一个删除信息的数据库窗体又该怎么写。。。。
 求大神。。求大牛。。。 求大腿缺挂件的。。。。。
 | 
 |