如何在SQL SERVERK上存储一个文件呢?
还有就是一点.存在此SQL SERVER上是数据吧.我给用户下载时是用超级链接的.那在文件系统中没有这个文件我要如何才能下载呢?
就像SharePoint那样,他东西都在SQL SERVER上.但是它还能像下一个硬盘上有的文件一样下载它.这是怎么完成的呢?

解决方案 »

  1.   

    http://support.microsoft.com/default.aspx?scid=kb;EN-US;309158
      

  2.   

    这个我看过了.我知道的呀,那是写到服务器本地文件系统的呀.如何把读到的数据不写到本地文件系统中就能让用户下载呢?就像SharePoing那样.
      

  3.   

    http://dotnet.aspx.cc/ShowDetail.aspx?id=EY1XLDYV-PIDF-43LO-1WFL-FMY5ALE1F635在SQL Server中保存和输出任意类型的文件
      

  4.   

    HTML:
    <input type="file" id="importfile" runat="server" name="importfile">
    用image来保存文件。
    上传:(filecontent字段为image类型)
    HttpFile hf = new HttpFile();
    byte [] filebyte =  hf.getFileByte(importfile.PostedFile);
    SqlConnection con = new SqlConnection();
    SqlCon sc = new SqlCon();
    string constr = sc.getconstr();

    con.ConnectionString = constr;
    con.Open();
    SqlDataAdapter adapter = new SqlDataAdapter("select * from i_monthAnalyse",con);
    SqlCommandBuilder Builder = new SqlCommandBuilder(adapter);
    DataSet ds = new DataSet();
    adapter.Fill(ds,"table");
    DataRow newrow;
    newrow = ds.Tables["table"].NewRow();
    newrow["person"] = Session["logonperson"].ToString();
    newrow["filename"] = hf.getFileName(importfile.PostedFile);
    newrow["filecontent"] = filebyte;
    newrow["filedate"] = DropDownList1.SelectedValue+"-"+DropDownList2.SelectedValue;
    ds.Tables["table"].Rows.Add(newrow);
    adapter.Update(ds,"table");
    con.Close();
    下载页面,把文件名做一个超联接到一个asp文件上:
    asp文件如下:
    Response.ContentType = "application/x-msdownload"Response.AddHeader "content-disposition", "attachment;filename=" & rs(0)
    Response.BinaryWrite(rs(1).GetChunk(7500000))
    rs(0)是文件名,rs(1)是image字段值