现在的位置: 首页 > 综合 > 正文

ACCESS的Ole对象读取

2012年07月16日 ⁄ 综合 ⁄ 共 777字 ⁄ 字号 评论关闭



Ole对象在Access中存储为二进制文件,读取的时候需要注意转换出的文件的编码格式

 1OleDbConnection OleConn = new OleDbConnection();
 2OleConn.ConnectionString =
@"
Provider=Microsoft.Jet.OleDb.4.0;data source=D:\WorkStation\Dialy_Sol\Dialy\Dialy.mdb";
 3OleDbCommand OleCmd = new OleDbCommand();
 4OleCmd.Connection = OleConn;
 5OleCmd.CommandType = CommandType.Text;
 6OleCmd.CommandText =
"
SELECT Dialy_Content FROM Dialy_Info WHERE Dialy_Date='2008-5-2'";
 7if (OleConn.State == ConnectionState.Closed)
 8{
 9OleConn.Open();
10}

11string DialyContent = "";
12byte[] Buff = new byte[1000];
13OleDbDataReader OleReader = OleCmd.ExecuteReader();
14while (OleReader.Read())
15{
16OleReader.GetBytes(00, Buff, 01000);
17DialyContent += Encoding.Unicode.GetString(Buff);
18}

<
/span>19<
span style="color: #000000;">

//
DialyContent就是
读取出来后的中文


抱歉!评论已关闭.