这是个实验程序,兄弟们帮我看看有什么毛病,运行起来太慢了,顺便看看有没有语法错误,小弟拜求!
---------------------------------------------------------------
private void Button1_Click(object sender, System.EventArgs e)
{
byte[] f=UpLoadFile(this.File1);
string DocName=System.IO.Path.GetFileNameWithoutExtension(this.File1.PostedFile.FileName.ToString()); string strSql_1="insert into docinfo(ID,DOCID,DOCNAME,DOCDIR,DOCBODY) values('1','4','"+DocName+"','c:\',EMPTY_BLOB())"; string strSql_2="update docinfo set DOCBODY=':f' where DOCID=4"; conn=new OleDbConnection(ConnectionString);
conn.Open();
cmd1=new OleDbCommand(strSql_1,conn);
cmd1.ExecuteNonQuery();
/**********************************************/
cmd2=new OleDbCommand(strSql_2,conn);
cmd2.ExecuteNonQuery();
}
--------------------------------------------------------
这是将文件转换成Byte类型的函数:public byte[] UpLoadFile(HtmlInputFile f1)
{
//获取由客户端指定的上传文件的访问
HttpPostedFile upFile=f1.PostedFile;
//得到上传文件的长度
int upFileLength=upFile.ContentLength; 
//得到上传文件的客户端MIME类型
string contentType = upFile.ContentType;
byte[] FileArray=new Byte[upFileLength];
 
Stream fileStream=upFile.InputStream; 
                
fileStream.Read(FileArray,0,upFileLength);
        
return FileArray; }