哪位大侠知道的,最好有代码!谢谢!

解决方案 »

  1.   

    http://sunnystar365.cnblogs.com/archive/2005/10/10/251410.aspx上面这个是保存图片,原理是一样的
      

  2.   

    先将DOC文件转换二进制流的形式,然后用SQL参数存储进数据库;
      

  3.   

    string path = "c://test.doc";
    string conn = "";//连接字符串
    FileStream file = new FileStream(path);
    byte[] buffer = new byte[1024*1024];
    int i1=0,i2=buffer.Length;
    while (i2 > 0)
    {
       int m = file.Read(buffer,0,buffer.Length);
       if (m <= 0) break;
       i1+=m;
       i2-=m;
    }
    byte[] temp = new byte[i1];
    Array.Copy(buffer,temp,i1);
    buffer = temp;
    SqlCommand cmd = new SqlCommand("insert into table1 value @doc" );
    ((SqlParameter)cmd.Parameters.Add("@doc",buffer)).DbType = DbType.Binary;
    cmd.Connection = new SqlConnection(conn).Open();
    int result = cmd.ExecuteNonQuery();
    cmd.Connection.Close();
      

  4.   

    To hainang1234(鼠 神 泪)
    运行你的代码后出现一个错误: 重载“FileStream”方法未获取“1”参数
    还有,我怎么可以将这doc文件从数据库中读出来呀??