文件上传到数据库,出现 范围超过int 的错误
gy348 2006-02-23 07:04:15 出现 范围超过int 的错误
代码如下:
可能是file 大到一定时候 len=f.Length 超过了 int
于是我把int len改成 long ...
网也就转到 无法显示网页 的页面了
FileInfo f=new FileInfo(address);
fileStream=f.OpenRead();
int len=f.Length
byte[] wordData=new byte[len]; //
int n=fileStream.Read(wordData,0,len); //这个len 超过int 。。。。。
string strSql="" ;
if(LbId.Text.Trim().Substring(0,1)=="1")
{
strSql="insert into ModifyRecord(id, studentid,submitdate,studentProj) values('"+LbId.Text+"','"+LbstudentID.Text+"','"+System.DateTime.Now.ToString()+"','+wordData+')";
}
else
{
strSql="insert into designRecord(id, studentid,submitdate,studentProj) values('"+LbId.Text+"','"+LbstudentID.Text+"','"+System.DateTime.Now.ToString()+"','+wordData+')";
}
SqlCommand cmd=new SqlCommand(strSql,cnn);
cnn.Open();
cmd.ExecuteScalar();
cnn.Close();
fileStream.Close();