简体   繁体   中英

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

This is my stored procedure for update teacher detail

 ALTER procedure [dbo].[sp_update_teacher]
     (@teacherid int,
      @name varchar(50),
      @gender int,
      @email varchar(50),
      @phone varchar(50),
      @address varchar(50),
      @timage image)
as
    update teacher_info 
    set teacher_name = @name,
        gender_id = @gender,
        teacher_mail = @email,
        phone = @phone,
        teacher_address = @address,
        image = @timage 
    where teacher_id = @teacherid

This is ado.net class code for update teacher detail

    public void update_info(int teacher_id, string teacher_name, int teacher_gender, string email, string teacher_phone, string teacher_address, byte[] image)
    {

        SqlConnection con = new SqlConnection("server=ARMAAN;database=smsystem;integrated security=true;");
        SqlCommand cmd = new SqlCommand("sp_update_teacher", con);
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.AddWithValue("@teacherid", teacher_id);
        cmd.Parameters.AddWithValue("@name", teacher_name);
        cmd.Parameters.AddWithValue("@gender", teacher_gender);
        cmd.Parameters.AddWithValue("@email", email);
        cmd.Parameters.AddWithValue("@phone", teacher_phone);
        cmd.Parameters.AddWithValue("@address", teacher_address);
        cmd.Parameters.AddWithValue("@timage", image);
        con.Open();
        cmd.ExecuteNonQuery();
        con.Close();
    }
}

This is update page code where i call the function that ii have made in class code

 protected void update_Click1(object sender, EventArgs e)

 {
    try
            {
                FileUpload img = (FileUpload)FileUpload2;
                Byte[] imgbyte = null;

                HttpPostedFile file = FileUpload2.PostedFile;
                imgbyte = new Byte[file.ContentLength];
                file.InputStream.Read(imgbyte, 0, file.ContentLength);

                tic.update_info(Convert.ToInt32(txt_id.Text), txt_name.Text, Convert.ToInt32(txt_genders.SelectedValue),txt_email.Text,txt_phone.Text, txt_address.Text, imgbyte);
                Response.Write("<script language='javascript'>alert('Teacher detail Update successfully') </script>");
                GridView1.DataSource = tic.getdata();
                GridView1.DataBind();
            }
            catch (Exception ex)
            {
                Response.Write("<script language='javascript'>alert('some error') </script>");
            }

        }

and it give me this error please tell me what should I do?

Try increasing the command timeout of the command:

    cmd.CommandTimeout = 120;

CommandTimeout

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM