ADO Net Database ASP.Net Tutorial

<%@ Page Language="C#" 
         AutoEventWireup="true" 
         CodeFile="Default.aspx.cs" 
         Inherits="Default" %>



    Linq-to-DataSets


    
        
            
            
                
        

    


File: Default.aspx.cs
using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
public partial class Default : System.Web.UI.Page
{
    protected void Button1_Click(object sender, EventArgs e)
    {
        string connString = "SERVER=(local);DATABASE=northwind;Trusted_Connection=yes;";
        string cmd = "SELECT * FROM customers;SELECT * FROM orders";
        SqlDataAdapter adapter = new SqlDataAdapter(cmd, connString);
        DataSet ds = new DataSet();
        adapter.Fill(ds);
        var customers = ds.Tables[0].AsEnumerable();
        var orders = ds.Tables[1].AsEnumerable();
        var data = from o in orders
                   join c in customers
                   on o.Field("CustomerID") equals c.Field("CustomerID")
                   where o.Field("OrderDate").Year == 1998 &&
                         o.Field("OrderDate").Month == 1 &&
                         o.Field("OrderDate").Day < 10
                   select new {OrderID=o.Field("OrderID"), 
                                Company=c.Field("CompanyName")};
        GridView1.DataSource = data; 
        GridView1.DataBind();
    }
}