更新dataset中的表在datagridview中显示

 DataSet ds = new DataSet();           
 da.Fill(ds,"tb_ZGIn");
 da.Dispose();

if (ds.Tables["tb_ZGIn"].Rows.Count == 0)
 {
    MessageBox.Show("没有查找到您所需要的结果");
 }
 bindingSource1.DataSource = ds.Tables["tb_ZGIn"];  //即使表中无数据也更新显示
 this.bindingNavigator1.BindingSource = bindingSource1;
 this.dataGridView1.DataSource = bindingSource1;
ds.Dispose();


<有问题>
OracleDataAdapter da = new OracleDataAdapter(strSql, conn);
 if (ds != null && ds.Tables.Contains("T_BJ_In"))
 {
ds.Tables["T_BJ_In"].Clear(); 
}

da.Fill(ds, "T_BJ_In");   
da.Dispose();
 if (ds.Tables["T_BJ_In"].Rows.Count == 0)

{
 MessageBox.Show("没有符合条件的数据");
 ds.Dispose();
 return;
 }
else
 {
 this.dataGridView1.Enabled = true;
bindingSource1.DataSource =ds.Tables["T_BJ_In"];
this.bindingNavigator1.BindingSource =bindingSource1;
this.dataGridView1.DataSource = bindingSource1;
}

你可能感兴趣的:(null,dataset)