Click here to Skip to main content
15,919,500 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Can Anyone answer how to rectify following error:


Error:


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


Coding:




protected void btnuppersonal_Click(object sender, ImageClickEventArgs e)
   {
       //string finduser = Request.QueryString["ids"].ToString();
       SqlConnection cn = new SqlConnection(ConfigurationManager.AppSettings["constring"].ToString());
       //SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["Connection"].ConnectionString);
       cn.Open();
       SqlCommand cmd = new SqlCommand();
       cmd.CommandText = "puppersonal";
       cmd.CommandType = CommandType.StoredProcedure;
       //cmd.Parameters.AddWithValue("@userid", Convert.ToInt32(Session["finduser"].ToString()));
       cmd.Parameters.AddWithValue("@userid", Convert.ToInt32(Session["pids"].ToString()));
       cmd.Parameters.AddWithValue("@fname", txtfname.Text);
       cmd.Parameters.AddWithValue("@lname", txtlname.Text);
       cmd.Parameters.AddWithValue("@gender", ddlgender.SelectedItem.Text);
       cmd.Parameters.AddWithValue("@altemailid", txtaltemail.Text);
       cmd.Parameters.AddWithValue("@mobile", txtmobile.Text);
       cmd.Parameters.AddWithValue("@phone", txtphone.Text);
       cmd.Parameters.AddWithValue("@address", txtaddress.Text);
       cmd.CommandTimeout = 0;
       cmd.Connection = cn;
       cmd.ExecuteNonQuery();   // Error Line
       cn.Close();
       //clear();
       Page.ClientScript.RegisterStartupScript(this.GetType(), "Updated", "<script>alert('Yor Pesonal details Updated sucessfully')</script>");

       txtfname.Text = "";
       txtlname.Text = "";
       ddlgender.SelectedItem.Text = "";
       txtaltemail.Text = "";
       txtphone.Text = "";
       txtaddress.Text = "";
   }
Posted
Updated 16-Feb-12 18:18pm
v3
Comments
manognya kota 13-Feb-12 23:52pm    
Where are you getting the error? Question not clear
M.Narmatha 13-Feb-12 23:53pm    
while updating
manognya kota 13-Feb-12 23:57pm    
Can you post the code how you are updating?
AmitGajjar 14-Feb-12 0:57am    
Question is not clear... elaborate it...

 
Share this answer
 
Hi,


I think you should adjust the Connection TimeOut and Command TimeOut...
See this link if could help you...

C#
How set CommandTimeout in Oracle.

 
Share this answer
 
v2
Hi,
this error normally specify that the database query that running is taking too long time.
you can change time out in your web.config file by changing "timeout=30" default.

refer following link for more details.
http://stackoverflow.com/questions/4308417/connection-timeout-for-sql-server[^]

https://forums.asp.net/p/1768926/4829628.aspx/1?SqlException+0x80131904+Timeout+expired+The+timeout+period+elapsed+prior+to+completion+of+the+operation+or+the+server+is+not+responding[^]

check the database query by using profiler. Hope this will helps.
 
Share this answer
 
v2
Verify your connection string into web.config and verify connection timeout. you had written commend timeout as zero as below

C#
cmd.CommandTimeout = 0;


update with below code

C#
cmd.CommandTimeout = 60;


it will be work.
 
Share this answer
 
Comments
M.Narmatha 16-Feb-12 6:47am    
that also not working...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900