If you're working with a database and provider that support
returning multiple resultsets, then you can accomplish this with
a DataAdapter.
string strConn, strSQL;
strConn = "Provider=SQLOLEDB;Data Source=(local);" +
"Initial Catalog=Northwind;Trusted_Connection=Yes;";
strSQL = "SELECT CustomerID, CompanyName FROM Customers " +
"WHERE CustomerID LIKE 'A%';" +
"SELECT OrderID, CustomerID, OrderDate FROM Orders " +
"WHERE CustomerID LIKE 'A%'";
OleDbDataAdapter da = new OleDbDataAdapter(strSQL, strConn);
DataSet ds = new DataSet();
da.Fill(ds);
You can also use the DataAdapter's TableMappings collection
to control the name of the DataTables that the DataAdapter
creates/uses.
da.TableMappings.Add("Table", "Customers");
da.TableMappings.Add("Table1", "Orders");
I hope this information proves helpful.
David Sceppa
Microsoft
This posting is provided "AS IS" with no warranties,
and confers no rights. You assume all risk for your use.
© 2003 Microsoft Corporation. All rights reserved.