小弟刚学C#,遇到个从数据库中读取文档的问题,特请教一下大家
小弟.cs文件代码如下:
        string path = @"F:\Website\fh2007.mdb";
        OleDbConnection conn = new OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=" + path);
        OleDbDataAdapter adp = new OleDbDataAdapter("Select CWNR from xm where xmbh='20075090050900002111'", conn);
        DataTable dt = new DataTable();
        adp.Fill(dt);
        Byte[] buffer = (byte[])dt.Rows[0][0];
        Response.Clear();
        Response.ContentType = "application/msword";
        Response.BinaryWrite(buffer);
        Response.End();运行程序之后下载了word文档,但无法正常打开,用写字板或word强制打开之后只写了"System.Byte[]"这一段文字请问如何才能正确将数据读取并显示出来,谢谢各位~~~

解决方案 »

  1.   

    那是因为你的word文档根本就没有存到数据库里面,呵呵!不知道对不对。
      

  2.   

    The Response.BinaryWrite method fails when you use it to send files that are larger than 20 MB
    suggest reading
    http://support.microsoft.com/kb/326502
      

  3.   

    我打开数据库看了,字段数据显示的是“长二进制数据”,应该是有数据的吧?to:jiangsheng,my file looks dosen't larger than 20MB, i saw that article,but it doesn't works.... :(
      

  4.   

    PS: 请教一下C#里面怎么获取Access中从“OLE 对象”取出的数据流的大小?
      

  5.   

    Byte[] buffer = (byte[])dt.Rows[0][0];你的数组没有内容啊
    要把dt.Rows中的内容用循环添加进来
      

  6.   

    大家这么一说,我都不知道究竟错误的环节究竟是储存还是读取了,那个字段又查看不了,我打了个包,麻烦哪位老大有空的话帮忙看看那个字段究竟有没有正确数据,是几个word。地址是:http://blog.armyonline.org/temp/fh2007.rar谢谢了~