Thread: Listing 12-13
View Single Post
  #4 (permalink)  
Old March 4th, 2006, 04:34 PM
kai kai is offline
Registered User
 
Join Date: Jan 2006
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by devinrader
 Posting a little more info about the error your seeing would be extremely helpful.

Devin
Hi, Devin

The following is the code I modified:

 protected void Page_Load(object sender, EventArgs e)
    {
        SqlConnection DBCon;
        SqlCommand Command = new SqlCommand();
        IAsyncResult ASyncResult;

        DBCon = new SqlConnection();
        Command = new SqlCommand();
        DBCon.ConnectionString =
          ConfigurationManager.ConnectionStrings["DSN_NorthWind"].ConnectionString;

        // Selecting top 5 records from the Orders table
        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();

        // Starting the asynchronous processing
        AsyncResult = Command.BeginExecuteReader(new AsyncCallback(CBMethod),
                                        CommandBehavior.CloseConnection);
    }

    public void CBMethod(IAsyncResult ar)
    {
        SqlDataReader OrdersReader;

        // Retrieving result from the asynchronous process
        OrdersReader = ar.EndExecuteReader(ar);

        // Displaying result on the screen
        gvOrders.DataSource = OrdersReader;
        gvOrders.DataBind();
    }


Thanks

Kai