<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="Default" %>
Create Data Reader
File: Default.aspx.cs
using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Text;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
DataSet data = new DataSet();
SqlDataAdapter adapter = new SqlDataAdapter(
"SELECT * FROM employees;SELECT * FROM customers",
ConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ConnectionString);
adapter.Fill(data);
DataTableReader reader = data.CreateDataReader();
StringBuilder builder = new StringBuilder();
do
{
while (reader.Read())
builder.AppendFormat("{0}
", reader[1]);
builder.Append("
");
} while (reader.NextResult());
reader.Close();
Label1.Text = builder.ToString();
}
}