private void button1_Click(object sender, EventArgs e)
        {
            dataGridView1.Rows.RemoveAt(dataGridView1.CurrentRow.Index);            conn = new SqlConnection(connString);
            SqlDataAdapter sda = new SqlDataAdapter("select * from dbo.Personal", conn);            DataSet ds = new DataSet();            sda.Fill(ds, "dbo.Personal");
            dataGridView1.AutoGenerateColumns = true;
            dataGridView1.DataSource = ds.Tables[0];
        }
该按钮为什么实现不了删除功能?

解决方案 »

  1.   

    只删除了DataGridView的数据,数据库的没有删除
      

  2.   

    这里边都没有删除的SQL语句,只是简单的查询功能。
      

  3.   

    只删除了gridview的数据, db的数据并没有删除dataGridView1.Rows.RemoveAt(dataGridView1.CurrentRow.Index);
    在这之后加上删除代码就OK了。
      

  4.   

    dataGridView1.Rows.RemoveAt(dataGridView1.CurrentRow.Index);
    这个只是删除当前你点击gdv这行的内容, 并没有删除数据库的
    这时写上 DELETE  TABLE1  WHERE ID=ID
      

  5.   

                    dataGridView1.Rows.RemoveAt(dataGridView1.CurrentRow.Index);
                     this.yqTableAdapter.Update(this.yqDataSet.yq);
      

  6.   

                    dataGridView1.Rows.RemoveAt(dataGridView1.CurrentRow.Index);
                    this.表名TableAdapter.Update(this.表名DataSet.yq);
      

  7.   

    ......第一次见到这么新鲜的删除...LZ你只删除了DataGridView中的行,并没有提交数据库所以不会有删除效果,而且删除也不是你这么做的......如有需要可以留下你的邮箱我发个GridView自带增删改查的DEMO给你~
      

  8.   

    [email protected]我的邮箱,谢谢
      

  9.   

    dataGridView1.Rows.RemoveAt(dataGridView1.CurrentRow.Index);
    只是删除了表格中的数据,又没删数据库中的。你再执行一个delete form 就行了
      

  10.   


    还要写个sql删除数据库中的相应数据。
      

  11.   

    LZ 你执行dataGridView1.Rows.RemoveAt(dataGridView1.CurrentRow.Index) 之后dataGridView中显示的数据行就被删除了,不用重新绑定数据把下边查询的操作换成删除的就OK了