Oracle BLOB数据类型为RichTextBox [英] Oracle BLOB datatype to RichTextBox
问题描述
我有一个有许多列的Oracle表。 BLOB数据类型中的这些列中的1个。
我在VB.NET中得到了一个简单的查询,它从该表中检索所有数据,并填充我的表单。但是,我在BLOB列中遇到了一些问题。
我有代码:
cmd.CommandText =select * from local_it.local_email_template where name ='& cb_EmailName.Text& '
dr = cmd.ExecuteReader
dr.Read()
tb_Username.Text = dr.Item(1)
tb_Password.Text = dr.Item (2)
tb_FromName.Text = dr.Item(3)
tb_FromEmail.Text = dr.Item(4)
tb_Host.Text = dr.Item(5)
n_Port .Value = dr.Item(6)
cb_Action.Text = dr.Item(7)
tb_Subject.Text = dr.Item(8)
rtb_Body.Text = dr.Item )
dr.Close()
但我得到一个错误 rtb_Body.text = dr.item(9)
,说
因此,我试图说
rtb_Body.text =
< dr.item(9).tostring ,但现在我只是得到文本
System.Byte [
因此我的问题是:写这个位(或我的查询),所以我得到实际文本在我的RichRextBox?
使用Visual Studio 2012,VB.NET在Oracle g11数据库
您可以使用 System.Text
/ p>
-
保存在blob字段中:
Dim blob_bytes_to_db As load()= System.Text.Encoding.ASCII.GetBytes(RichTextBox1.Rtf)
-
into richtextbox:
RichTextBox1.Rtf = System.Text.Encoding.ASCII.GetChars(blob_bytes_from_db)
:使用RichTextBox1
.Text
> 属性可以获取/设置纯文本。如果要获取/设置带有所有RTF代码的格式化文本,请使用 .Rtf
属性。 I got an Oracle table with a number of columns. 1 of these columns in a BLOB datatype. I got a simple query in VB.NET that is retrieving all data from this table, and populates my form. However, I'm having some problems with the BLOB column.
I have this bit of code:
cmd.CommandText = "select * from local_it.local_email_template where name = '" & cb_EmailName.Text & "'"
dr = cmd.ExecuteReader
dr.Read()
tb_Username.Text = dr.Item(1)
tb_Password.Text = dr.Item(2)
tb_FromName.Text = dr.Item(3)
tb_FromEmail.Text = dr.Item(4)
tb_Host.Text = dr.Item(5)
n_Port.Value = dr.Item(6)
cb_Action.Text = dr.Item(7)
tb_Subject.Text = dr.Item(8)
rtb_Body.Text = dr.Item(9)
dr.Close()
But I'm getting an error on the line rtb_Body.text = dr.item(9)
, saying
Conversion from type 'Byte()' to type 'String' is not valid
So I tried to say rtb_Body.text = dr.item(9).tostring
, but now I just get the text
System.Byte[]
in my RichRextBox.
So my question is: How do I write this bit (or my query for that matter) so I get the actual text in my RichRextBox?
Working with Visual Studio 2012, VB.NET on an Oracle g11 Database
You can use enconding functions from System.Text
namespace:
for save in blob field:
Dim blob_bytes_to_db As Byte() = System.Text.Encoding.ASCII.GetBytes(RichTextBox1.Rtf)
for load blob into richtextbox:
RichTextBox1.Rtf = System.Text.Encoding.ASCII.GetChars(blob_bytes_from_db)
Note: With RichTextBox1 .Text
property can get/set clean text only. If you want to get/set formatted text with all RTF codes, use .Rtf
property.
这篇关于Oracle BLOB数据类型为RichTextBox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!