操作数据库,更新dataset,重新绑定datagrid就行了

解决方案 »

  1.   

    dataSet11.book_inf.Rows[dataGrid1.CurrentRowIndex].Delete();
    oleDbDataAdapter1.Update(dataSet11.book_inf );
      

  2.   

    string clientname=dsClientInfo.Tables[0].Rows[ clientinfogrid.CurrentRowIndex ][0].ToString();
    DialogResult rs=MessageBox.Show( this,"你确定要删除客户["+clientname+"]吗?","提示",MessageBoxButtons.OKCancel,MessageBoxIcon.Question );

    if( rs==DialogResult.OK ){

    try{
    ClientInfo c=new ClientInfo( Application.StartupPath );
    c.delClientInfo( clientname );
    MessageBox.Show( this,"删除成功!" );
    refreshResult();
    }
    catch( Exception ex ){
    MessageBox.Show( this,ex.Message );
    return;
    }
      

  3.   

    更新dataset,重新绑定datagrid就行了
      

  4.   

    各位,谁有这样的代码可以参考一下,有关winform的,不是web的.谢谢!
      

  5.   

    加上它:
    private System.Windows.Forms.BindingManagerBase mybind;
    事件:
    this.sqlDeletecmd1.CommandText = "delete authors where zip='"+this.dataSet1.Tables["authors"].Rows[mybind.Position]["zip"].ToString()+"'";
    try
    {
    this.sqlConnection1.Open();
    this.sqlDeletecmd1.ExecuteNonQuery();
    this.sqlConnection1.Close();
       this.dataSet1.Reset();
    this.sqlSelectcmd1.CommandText = "select * from authors"
                               this.sqlDataAdapter1.Fill(this.dataSet1,"authors");
    this.dv = this.dataSet1.Tables["authors"].DefaultView;
    this.dv.AllowNew = false;
    this.dv.AllowEdit = false;
    this.dv.AllowDelete = false;
    this.mybind = this.BindingContext[this.dv];
    this.mybind.PositionChanged += new EventHandler(this.mybind_PositionChanged);
    this.dataGrid1.DataSource = this.dv; }
    catch(System.Data.SqlClient.SqlException ex)
    {
    if(this.sqlConnection1.State == System.Data.ConnectionState.Open)
    this.sqlConnection1.Close();
    MessageBox.Show(ex.ToString());
    }
      

  6.   

    http://www.cnblogs.com/rudyshen/archive/2004/07/30/28581.aspx