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

OracleDataAdapter填充DataSet的问题
能否用同一个OracleDataAdapter向同一个DataSet中多次添加不同查询结果
比如:
str   =   "SELECT   *   FROM   TBL_STEP   WHERE   ULD_ID   =     1   AND   TRANS_ORT   =   '正向 ' ";
OracleConnection   conn=new   OracleConnection(ConnectionString);
OracleDataAdapter   oda   =   new   OracleDataAdapter   (str,conn);
DataSet   ds   =   new   DataSet   ();
oda.Fill   (ds, "tbl_step ");.//第一次填充
//能否这样用
str   =   "SELECT   *   FROM   PATH ";//是SELECT查询,不是UPDATE,DELETE等
oda.SelectCommand.CommandText   =   str;
oda.SelectCommand   .Connection   =   conn;
oda.Fill   (ds, "PATH ");.//
我这样做提示是错误的,如果可以用,正确格式怎么写?

------解决方案--------------------
OracleConnection conn=new OracleConnection(ConnectionString);
string str = "SELECT * FROM TBL_STEP WHERE ULD_ID = 1 AND TRANS_ORT = '正向 ';SELECT * FROM PATH ";
OracleDataAdapter oda = new OracleDataAdapter (str,conn);
DataSet ds = new DataSet();
//将TBL_STEP1 的源表映射到 DataSet 表 PATH
oda.TableMappings.Add( "TBL_STEP1 ", "PATH ");
oda.Fill(ds);
for(int i = 0 ; i < ds.Tables.Count ; i ++ )
Response.Write(ds.Tables[i].TableName + " <br /> ");
------解决方案--------------------
错误提示是什么?