小弟刚学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[]"这一段文字请问如何才能正确将数据读取并显示出来,谢谢各位~~~
小弟.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[]"这一段文字请问如何才能正确将数据读取并显示出来,谢谢各位~~~
suggest reading
http://support.microsoft.com/kb/326502
要把dt.Rows中的内容用循环添加进来