使用DataAdapter的Fill方法返回包含多个数据表的DataSet

在DataAdapter的SelectCommand的CommandText中直接采用批查询

例如:

 strSql = "SELECT * FROM Orders;SELECT * FROM Customers";
 SqlDataAdapter daData = new SqlDataAdapter(strSql,new SqlConnection("server=XLZHU;User ID=sa;Password=111111;database=Northwind"));
 //daData.TableMappings.Add("Table","Order_Info");
 //daData.TableMappings.Add("Table1","Customer_Info");
 DataSet dsData = new DataSet();
 daData.Fill(dsData); 

这样,dsData中就会有两个DataTable,分别为Table和Table1(去掉注释名称就为Order_Info和Customer_Info)

posted @ 2011-01-11 09:49  快乐的langYa  阅读(748)  评论(0编辑  收藏  举报