ACCESS的Ole对象读取
Ole对象在Access中存储为二进制文件,读取的时候需要注意转换出的文件的编码格式
1
OleDbConnection OleConn = new OleDbConnection();
2
OleConn.ConnectionString =
@"Provider=Microsoft.Jet.OleDb.4.0;data source=D:\WorkStation\Dialy_Sol\Dialy\Dialy.mdb";
3
OleDbCommand OleCmd = new OleDbCommand();
4
OleCmd.Connection = OleConn;
5
OleCmd.CommandType = CommandType.Text;
6
OleCmd.CommandText =
"SELECT Dialy_Content FROM Dialy_Info WHERE Dialy_Date='2008-5-2'";
7
if (OleConn.State == ConnectionState.Closed)
8
{
9
OleConn.Open();
10
}
11
string DialyContent = "";
12
byte[] Buff = new byte[1000];
13
OleDbDataReader OleReader = OleCmd.ExecuteReader();
14
while (OleReader.Read())
15
{
16
OleReader.GetBytes(0, 0, Buff, 0, 1000);
17
DialyContent += Encoding.Unicode.GetString(Buff);
18
}
< /span>19< span style="color: #000000;">
//DialyContent就是
读取出来后的中文
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
2
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
@"Provider=Microsoft.Jet.OleDb.4.0;data source=D:\WorkStation\Dialy_Sol\Dialy\Dialy.mdb";
3
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
4
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
5
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
6
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
"SELECT Dialy_Content FROM Dialy_Info WHERE Dialy_Date='2008-5-2'";
7
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
8
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
9
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
10
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
11
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
12
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
13
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
14
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
15
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
16
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
17
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
18
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
< /span>19< span style="color: #000000;">
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)