各个大虾们好了
     我想把我上传的文件写入到数据库中怎么实现呀,有什么注意事项?有范例吗?谢谢了!!!

解决方案 »

  1.   

    可以,这个字段用image类型不过楼主为什么要这么做?
      

  2.   

    image上传源代码private void submit_Click(object sender, System.EventArgs e)
    {
    Stream imgStream;
    int docSize;
    string docName;
    string imgContentType;
    string imgUploadedName;
    imgStream  = this.Up_file.PostedFile.InputStream;      //二进制流
    docSize =  this.Up_file.PostedFile.ContentLength;      //文件大小
    imgUploadedName = this.Up_file.PostedFile.FileName;    //文件名称
    byte[] docBody=new byte[docSize];
    imgContentType = this.Up_file.PostedFile.ContentType;  //文件类型
    docName =imgUploadedName.Substring(imgUploadedName.LastIndexOf('\\')+1);
    int n = imgStream.Read(docBody, 0, docSize);  
    DataTable temp = mynew.Get_ZH_EngBriefing_byoid(0);   //返回一个空的table
    DataRow row = temp.NewRow();
    //.....省略其他保存代码
    row["DOWN_PATH"] = docBody;   //保存数据到数据库,DOWN_PATH字段为二进制
    row["FILENAME"] = docName;       //保存文件名称
    row["LX"] = imgContentType;       //保存文件类型
    temp.Rows.Add(row);
    mynew.SaveZHEngBriefing(temp);  
    }
    <tr bgcolor="#ffffff">
       <td height="24">
     <input type="file" id="Up_file" class="edline" runat="server" style="WIDTH: 456px; HEIGHT: 20px" size="60" name="Up_file">
       </td>
    </tr>
    <TR bgcolor="#ffffff">
      <TD height="24" align="center">
         <asp:Button ID="submit" Runat="server" Text="文件上传" CssClass="Cmdbut" Height="20px"></asp:Button>
      </TD>
    </TR>
      

  3.   

    你可以用随机函数来产生文件名.或者用
    system.datetime.now.year & system.datetime.now.month
    一直取到毫秒为止,为产生一个不重复的文件名即可.
      

  4.   

    有人帮我吗??/
     Asp.net中如何把DataGrid中的数据打印出来,C#语言,急,谢谢!