using System;
using System.Data;
using System.Data.SqlClient;
class Program
{
static void Main(string[] args)
{
string sqlConnectString = "Data Source=(local);" +
"Integrated security=SSPI;Initial Catalog=AdventureWorks;";
string sqlSelect = "SELECT TOP 3 * FROM Sales.SalesOrderHeader;" +
"SELECT TOP 3 * FROM Sales.SalesOrderDetail";
int rsNumber;
SqlDataAdapter da = new SqlDataAdapter(sqlSelect, sqlConnectString);
DataSet ds = new DataSet( );
da.Fill(ds);
rsNumber = 0;
foreach (DataTable dt in ds.Tables){
Console.WriteLine("Result set: {0}", ++rsNumber);
foreach (DataRow row in dt.Rows){
Console.WriteLine("{0}, {1}, {2}", row[0], row[1], row[2]);
}
}
}
}
|