Issue resolved
The below solution works for me. Let me know if anyone encounters any issue with the stated solution.
SqlCommand cmd = new SqlCommand();
protected void Page_Load(object sender, EventArgs e)
{
IAsyncResult result;
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrin gs["MyConn"].ConnectionString);
cmd.CommandText = "Select Top 3 * from [Customers]";
cmd.CommandType = CommandType.Text;
cmd.Connection = conn;
cmd.Connection.Open();
result = cmd.BeginExecuteReader(new AsyncCallback(CBMethod), CommandBehavior.CloseConnection);
System.Threading.Thread.Sleep(5000);
}
public void CBMethod(IAsyncResult result)
{
SqlDataReader dr;
dr = cmd.EndExecuteReader(result);
GV1.DataSource = dr;
GV1.DataBind();
}
|