asp使用的ado就可以啊.  appendchunk方法就可以

解决方案 »

  1.   

    是的啊!同意楼上 amorg(飘雪)的!应该没有问题的
      

  2.   

    请amorg兄详细点,好吗?BLOB字段中的word,excel文档如何写到IE?WORD,EXCEL文档如何从客户端写入服务器中的BLOB字段?
      

  3.   

    现在贴代码,有两个WEBFORM,另外一个用来打开文件。
    我有完整的ASPX及CS文件
    1.输入 private void Button1_Click(object sender, System.EventArgs e)
    {
    string Inf_Title = Inf_TitleTextBox.Text.ToString().Trim();
    if (Inf_Title == "")
    {
    MessLabel.Text = "标题不能为空!";
    return;
    } string Inf_Name = Inf_NameTextBox.Text.ToString().Trim();
    if (Inf_Name == "")
    {
    MessLabel.Text = "发布人不能为空!";
    return;
    } string InvType = InvTypeTextbox.Text.ToString().Trim();
    if (InvType == "")
    {
    MessLabel.Text = "型号不能为空!";
    return;
    } if (SelectFile.PostedFile == null)
    {
    MessLabel.Text = "请你选择你要上传的文件"; 
    return;
    } HttpPostedFile UpFile = SelectFile.PostedFile;  //HttpPostedFile对象,用于读取文件属性
    FileLength = UpFile.ContentLength;     //记录文件长度  try 
    {
    if (FileLength == 0) 
    {   //文件长度为零时
    MessLabel.Text = "请你选择你要上传的文件"; 

    else 
    {
    Byte[] FileByteArray = new Byte[FileLength];   //文件临时储存Byte数组
    Stream StreamObject = UpFile.InputStream;      //建立数据流对像
    //读取文件数据,FileByteArray为数据储存体,0为数据指针位置、FileLnegth为数据长度
    StreamObject.Read(FileByteArray,0,FileLength);   
    //建立SQL Server链接
    String SQLStatement = "INSERT INTO Information(标题, 时间, 撰稿人, ImageData, ImageContentType, ImageSize, ImageClass, InvType, 内容) VALUES (@Inf_Title, Getdate(), @Inf_Name, @ImageData, @ImageContentType, @ImageSize, @ImageClass, @InvType, @Inf_Text)";
    SqlCommand myCommand = new SqlCommand(SQLStatement,CNN.AOSmithsqlConnection);
    myCommand.Parameters.Add("@Inf_Title", SqlDbType.Char,120).Value = Inf_Title;  //标题
    myCommand.Parameters.Add("@Inf_Name", SqlDbType.VarChar,20).Value = Inf_Name;  //撰稿人
    myCommand.Parameters.Add("@ImageData",SqlDbType.Binary, FileLength).Value = FileByteArray; //上传文件
    myCommand.Parameters.Add("@ImageContentType", SqlDbType.VarChar,50).Value = UpFile.ContentType;  //记录文件类型
    myCommand.Parameters.Add("@ImageSize", SqlDbType.BigInt,8).Value = UpFile.ContentLength; //记录文件长度,读取时使用
    myCommand.Parameters.Add("@ImageClass", SqlDbType.VarChar,10).Value = Session["ImageClass"].ToString();
    myCommand.Parameters.Add("@InvType", SqlDbType.Char,20).Value = InvType;
    myCommand.Parameters.Add("@Inf_Text", SqlDbType.Text,Inf_TextTextBox.Text.Length).Value = Inf_TextTextBox.Text;
    CNN.AOSmithsqlConnection.Open();
    myCommand.ExecuteNonQuery();
    CNN.AOSmithsqlConnection.Close();
    MessLabel.Text = "<p><b>OK!你已经成功上传你的文件</b>";//提示上传成功
    BindDatas();
    }

    catch (Exception ex) 
    {
    MessLabel.Text = ex.Message.ToString();
    }
    }
    2.输出
    private void Page_Load(object sender, System.EventArgs e)
    {
    // 在此处放置用户代码以初始化页面
    if (!IsPostBack)
    {
    String SQLStatement = "SELECT * FROM Information WHERE ImageID = " +  Session["ImageID"].ToString().Trim();
    SqlCommand myCommand = new SqlCommand(SQLStatement,CNN.AOSmithsqlConnection);
    CNN.AOSmithsqlConnection.Open(); SqlDataReader SqlReader = myCommand.ExecuteReader();
    SqlReader.Read();     
    Response.ContentType = (string)SqlReader["ImageContentType"];//设定输出文件类型
    //输出图象文件二进制数制
    Response.OutputStream.Write((byte[])SqlReader["ImageData"], 0, (int)SqlReader["ImageSize"]);     
    Response.End();
    CNN.AOSmithsqlConnection.Close();
    } }