file = Request.QueryString["word"];
file = Server.MapPath(file);
if( !File.Exists(file) )
{
    Response.Write("没找到该文件");
    Response.End;
}
FileStream fs = new FileStream(file, FileMode.Open, FileAccess.Read);
byte[] bt = new byte[fs.Length];
fs.Read( bt, 0, fs.Length );
fs.Close();//插入数据库中
OleDbConnection con = new OleDbConnectin("连接字符串");
OleDbCommand cmd = con.CreateCommand();
cmd.CommandText = "Insert into [FILE] (FileData) Values (@FileData)";
cmd.Parameters.Add("@FileData",OleDbType.Binary).Value = bt;
con.Open();
cmd.ExecuteNonQuery();
con.Close();

解决方案 »

  1.   

    我的file为绝对路径怎么做,file是在客户端的文件夹里!
      

  2.   

    你的意思是通过地址直接把客户端的WORD上传的数据库?不行!
    我上面的代码是把服务器上的文件传到数据库中,不是客户端文件!
      

  3.   

    我现在老板就是这样要求的,word文件在客户端,
      

  4.   

    客户端WORD文件的地址写到数据库里,有什么作用?
      

  5.   

    让客户端上传这个文件。(“推”到服务器)是不是要用file这个控件,要是用这个肯定
    是不可以的,还用没有其它的方法??