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