// Arquivo de exemplo: SQlCache.aspx.cs
using System;
using System.Data;
using System.Web.UI;
using System.Data.SqlClient;
using System.Configuration;

public partial class SQlCache : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            DataView origem;
            ConnectionStringSettings getString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["nwind"] as ConnectionStringSettings;
            if (getString != null)
            {
                string sSql = "select Products.ProductName, Products.QuantityPerUnit, Products.UnitPrice from Products";

                DataSet ds = new DataSet();
                using (SqlConnection conn = new SqlConnection(getString.ConnectionString))
                {
                    SqlCommand cmd = new SqlCommand(sSql, conn);
                    cmd.CommandType = CommandType.Text;

                    SqlDataAdapter adapter = new SqlDataAdapter(cmd);
                    adapter.Fill(ds);
                    origem = new DataView(ds.Tables[0]);
                }
                Dt1.DataSource = origem;
                Dt1.DataBind();
            }
        }
    }
}

