请教高手 c# Merge 问题

来源:百度知道 编辑:UC知道 时间:2024/06/22 06:44:18
string strSQL1="sql语句"
string strSQL2="sql语句"
string strSQL2="sql语句"
DataSet ds=SQLServerDAL.SQLDAL .Query_GH (strSQL1);

DataSet ds1= SQLServerDAL.SQLDAL .Query_GH(strSQL2);
DataSet ds2=SQLServerDAL.SQLDAL .Query_GH (strSQL3);
dg_1.DataSource = ds;
dg_1.DataBind();
dg_1.DataSource = ds1;
dg_1.DataBind();
dg_1.DataSource = ds2;
dg_1.DataBind();
Session["ds"] = ds;
Session["ds1"] = ds1;
Session["ds2"] = ds2;
private void btnOK_Click(object sender, System.EventArgs e)
{
DataSet ds = (DataSet)Session["ds"];
DataSet ds1 = (DataSet)Session["ds1"];
DataSet ds2 = (DataSet)Session["ds2"];
ds.Merge (ds1);
ds.Merge (ds2 );
this.dg_1.DataSource= ds ; //datagrid绑定
this.dg_1.DataBind();
}
merge方法里面用ds.Merge(ds2.tablesp[&qu

try
{
DataSet ds = (DataSet)Session["ds"];
DataSet ds1 = (DataSet)Session["ds1"];
DataSet ds2 = (DataSet)Session["ds2"];

}
catch{}
..
这里Session里面未必有值

你给表指定一个表明不就行了,不用表明也可以用索引的吧

不需要,你直接指向数据集就可以了

现在提示我ds.Merge (ds1)未将对象引用设置到对象的实例,ds为null或者ds1为null