ADO Net Database ASP.Net Tutorial

<%@ Page Language="C#" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Configuration" %>

    Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) 
        Dim DBCon As SqlConnection
        Dim Command As SqlCommand = New SqlCommand()
        Dim ASyncResult As SqlAsyncResult
        DBCon = New SqlConnection()
        Command = New SqlCommand()
        DBCon.ConnectionString = _
        ConfigurationManager.ConnectionStrings("DSN_NorthWind").ConnectionString
        Command.CommandText = _
                "SELECT TOP 5 Customers.CompanyName, Customers.ContactName, " & _
                " Orders.OrderID, Orders.OrderDate, " & _
                " Orders.RequiredDate, Orders.ShippedDate " & _
                " FROM Orders, Customers " & _
                " WHERE Orders.CustomerID = Customers.CustomerID " & _
                " ORDER BY Customers.CompanyName, Customers.ContactName "
        Command.CommandType = CommandType.Text
        Command.Connection = DBCon
        DBCon.Open()
        AsyncResult = Command.BeginExecuteReader(New _
           AsyncCallback(AddressOf CBMethod), CommandBehavior.CloseConnection)
    End Sub
    Public Sub CBMethod(ByVal ar As SQLAsyncResult)
        Dim OrdersReader As SqlDataReader
        OrdersReader = ar.EndExecuteReader(ar)
        gvOrders.DataSource = OrdersReader
        gvOrders.DataBind()
    End Sub



    The Call Back Approach


    
    

            Runat="server">
        
                    DataField="CompanyName">
                    DataField="ContactName">
                    DataFormatString="{0:d}">
                    DataFormatString="{0:d}">
                    DataFormatString="{0:d}">
        

     
    

    


File: Web.config

  
                     connectionString="Data Source=localhost\SQLEXPRESS;Initial Catalog=Northwind;Integrated Security=True"
             providerName="System.Data.SqlClient" />