日期:2014-05-19  浏览次数:20965 次

dataGridView更新数据源问题
public   SqlDataAdapter   GetPersonRedeploy(string   cPsnNum)                 {
                        string   selectStr   =   "select   *   from   person   where   person.cPsn_Num= ' "   +   cPsnNum   +   " ' ";
                        this.sqlC   =   new   SqlConnection(DBOperate.connectStr);
                        this.sqlCmd   =   new   SqlCommand(selectStr,   this.sqlC);
                        this.sqlC.Open();
                        this.sqlDa   =   new   SqlDataAdapter(sqlCmd);
                        return   this.sqlDa;
                }
SqlDataAdapter   sda   =   dbop.GetPersonRedeploy(dataGridView1.CurrentCell.Value.ToString());
                                DataTable   table   =   new   DataTable();
                                sda.Fill(table);
                                bindingSource2.DataSource   =   table;
                                dataGridView2.DataSource   =   bindingSource2;
我从person取出数据,并把它填充到dataGridView2中,dataGridView2中启用删除和编辑,可是要怎么样才能更新数据源呢?

------解决方案--------------------
sqldataAdapter.update(yourdataTAble);

------解决方案--------------------
SqlDataAdapter.Update(DataTable dataTable)