我尝试读取Oracle BLOB字段并将内容显示为richTextBox.我在谷歌找到的例子几乎相同,但我仍然无法让它工作.
我知道BLOB字段包含序列化数据.
这是我到目前为止:
(连接读者工作正常)
private void button1_Click_1(object sender, EventArgs e)
{
//testen of een blob is uit te lezen
OracleCommand cmd = new OracleCommand();
cmd.Connection = OraConnection.conn;
cmd.CommandText = "select id, blobfield from test_table where id = '20ED7EDB-406A-43E8-945B-5E63DFCBA7FF'";
cmd.CommandType = CommandType.Text;
OracleDataReader dr = cmd.ExecuteReader();
dr.Read();
OracleBlob BLOB1 = dr.GetOracleBlob(1);
Byte[] Buffer = (Byte[])(dr.GetOracleBlob(1)).Value;
string lookupValue = System.Text.ASCIIEncoding.ASCII.GetString(Buffer);
richTextBox1.Text += lookupValue; //shows: DQStream
richTextBox1.Text += "";
richTextBox1.Text += "1";
richTextBox1.Text += dr.GetOracleBlob(1).Value; //shows: System.Byte[]
richTextBox1.Text += "";
}