这是我更新教师详细信息的存储过程
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();
}
}
这是更新页面代码,我调用我在类代码中创建的函数
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>");
}
}
它给我这个错误请告诉我该怎么办?