繁体   English   中英

超时已过。 操作完成前超时时间已过或服务器未响应

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

这是我更新教师详细信息的存储过程

 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

这是用于更新教师详细信息的 ado.net 类代码

    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();
    }
}

这是更新页面代码,我在其中调用了 ii 在类代码中创建的函数

 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>");
            }

        }

它给了我这个错误请告诉我我该怎么办?

尝试增加命令的命令超时:

    cmd.CommandTimeout = 120;

命令超时

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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