Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding in windows appilcation


 
While trying to use windows application, I got a peculiar timout error.

SqlCommand cmd = new SqlCommand("My_Report_Proc", conn);
cmd.CommandType = CommandType.StoredProcedure;

//dataGridView1.DataSource = cmd.ExecuteReader();
// bind the data source to the datagrid
//dataGridView1.databind();
// close the connection to the database since we are done using it
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(ds);   --Got the error at this point
dataGridView1.DataSource = ds.Tables[0];

 
Error string:
Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding in windows appilcation
I have tried adding connection timout (Connect Timeout=500;). Still, the problem is not resolved. After wards, I have added the command cmd.CommandTimeout = 0; This issue is resolved.
 

conn.Open();
SqlCommand cmd = new SqlCommand("My_Report_Proc", conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandTimeout = 0;
//dataGridView1.DataSource = cmd.ExecuteReader();
// bind the data source to the datagrid
//dataGridView1.databind();
// close the connection to the database since we are done using it
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(ds);
dataGridView1.DataSource = ds.Tables[0];
//GridView.DataBind()
 
 
Cheers,
Venkatesan Prabu .J