主要方法如下://图片能插入成功,但就是类型不对.
HttpPostedFile HPF=File1.PostedFile;       //将文件域F上传的文件赋给HPF--------
int FL=HPF.ContentLength;
if(FL != 0)
  {
   string FT=HPF.ContentType;
   Byte[] FBA=new Byte[FL];//声明一个字节数组FBA,用于存放文件的数据流
    Stream SO;//声明流对象SO
   SO=HPF.InputStream;//将上传文件的输入流赋予SO
   SO.Read(FBA,0,FL);//流对象SO执行Read方法将输入流读入字节数组FBA
   string strsql1 = "Insert into Productsinfo (ID,Photo,FileLength,ContentType) Values ('8',@fs,'"+FL+"','"+FT+"')";
           //调用类dbhelp中方法ExecuteSqlInsertImg将图片插入到数据库,返回受影响的行数.
   this.Label2.Text = dbhelp.ExecuteSqlInsertImg(strsql1,FBA).ToString();
}例如:
插入一张GIF图片到数据库后,FileLength显示的内容是application/octet-stream,而不是image/gif记录为:     ID     Photo          FileLength                     ContentType   
     1     <Binary>        application/octet-stream         86302 我要是这种结果:     ID     Photo          FileLength                     ContentType   
     1     <Binary>        image/gif                         86302