datagridview 删除数据行

来源:互联网 发布:windows程序管理器 编辑:程序博客网 时间:2024/05/21 17:57

//ok 删除数据成功
            SqlConnection conn = new SqlConnection(str);
              
            SqlDataAdapter da = new SqlDataAdapter();
            DataSet ds = new DataSet();
                        SqlCommand sqlcommand = new SqlCommand("select * from 科目表 where 科目代码='"+textBox1 .Text +"'",conn );
            da.SelectCommand = sqlcommand;
            da.Fill(ds, "科目表");
            ds.Tables[0].Rows[0].Delete();
          
            SqlCommandBuilder sqlcommandbuilder = new SqlCommandBuilder(da);
            da.Update(ds, "科目表");
            dataGridView1.DataSource = ds;
         

上面的代码能够删除一行

但是没能得到想要的效果

删除后没能在datagridview中显示出来

 

该是哪个地方我写的方式不正确吧

 

原创粉丝点击