超时时间已到。在操作完成之前超时时间已过或服务器未响应?
CZ_ZT 2011-07-12 08:54:48 string ID = STUCurrUser;
{
SqlConnection sqlStr = new SqlConnection(sqltxt);
sqlStr.Open();
//二进制格式化器
BinaryFormatter bf = new BinaryFormatter();
//内存流
MemoryStream ms = new MemoryStream();
//把图片格式化成二进制保存在内存流中
bf.Serialize(ms, this.StuPhoto.Image);
//转换成字节数组
byte[] arr = ms.ToArray();
//@image变量
string update = string.Format("update tb_student set stuPhoto=@StuPhoto where stuID='{0}' ",ID);
SqlCommand mycmd = new SqlCommand(update, sqlStr);
//给变量赋值
mycmd.Parameters.Add("@StuPhoto", SqlDbType.Image).Value = arr;
int i = mycmd.ExecuteNonQuery();
if (i > 0)
{
MessageBox.Show("照片上传成功", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
sqlStr.Close();
}
我打算上传照片保存到SQL数据库,但是点击上传的时候,他显示了超时时间已到。在操作完成之前超时时间已过或服务器未响应?这要如何解决?
还有,我想在查看他人的资料的时候显示他们的照片,但一些人有照片,一些没有,我想在查看的时候,去判断他SQL里面是否有属于他的照片。如果有,就显示出来,如果没有,就不用显示。我之前想试用count(image)去判断,但他说image的类型无法用count,请问要如何让解决