lmpsteelwire
asked on
converting BLOB to String
hey guys, I need a select statement that convert a blob, and bring me back a string
i know for sure, everytime, that the blob is just plain old text. Is there anyway to do that?
i know for sure, everytime, that the blob is just plain old text. Is there anyway to do that?
ASKER
Either oracle or VB.net....but if vb.net, im using oracleclient dll
OK
Here is one of the VB solutions to convert BLOB to string.
After getting the BLOB from the oracle
Dim sAns As String
Dim iPos As String
sAns = StrConv(GetAttachment, vbUnicode) ' GetAttachment is BLOB
iPos = InStr(sAns, Chr(0))
If iPos > 0 Then sAns = Left(sAns, iPos - 1)
GetAttachment = sAns
Hope this helps.
JanMah
Here is one of the VB solutions to convert BLOB to string.
After getting the BLOB from the oracle
Dim sAns As String
Dim iPos As String
sAns = StrConv(GetAttachment, vbUnicode) ' GetAttachment is BLOB
iPos = InStr(sAns, Chr(0))
If iPos > 0 Then sAns = Left(sAns, iPos - 1)
GetAttachment = sAns
Hope this helps.
JanMah
ASKER
im using vb.net, not vb
well i am sure you can change it to .Net, you can't expect all as piece of cake, huh?
JanMah
JanMah
ASKER
I could convert it...
but I dont know how to bring a blob in from the database to my vb/vb.net
but I dont know how to bring a blob in from the database to my vb/vb.net
OK.. here we go
The SQL will be
Select * from TableName where ID = <ID>
Nothing special here.
After getting it in recordset, use
Dim sAns As String
Dim iPos As String
Dim bGetAttachment as Byte()
bGetAttachment = rs("Attachment").GetChunk( rs("Attach ment").Act ualSize)
sAns = StrConv(bGetAttachment, vbUnicode) ' GetAttachment is BLOB
iPos = InStr(sAns, Chr(0))
If iPos > 0 Then sAns = Left(sAns, iPos - 1)
GetAttachment = sAns
janMah
The SQL will be
Select * from TableName where ID = <ID>
Nothing special here.
After getting it in recordset, use
Dim sAns As String
Dim iPos As String
Dim bGetAttachment as Byte()
bGetAttachment = rs("Attachment").GetChunk(
sAns = StrConv(bGetAttachment, vbUnicode) ' GetAttachment is BLOB
iPos = InStr(sAns, Chr(0))
If iPos > 0 Then sAns = Left(sAns, iPos - 1)
GetAttachment = sAns
janMah
ASKER
StrConv wont take a byte array.
well, it will take. Have you checked it?
ASKER
nevermind. I used another question on EE to answer that last part...thanks man.
is inserting a string back into oracle as a blob just the same?
is inserting a string back into oracle as a blob just the same?
yes, if you want to just strore the string just because, it is more than 4000 char long, then I would suggest you to go for clob.
If you want to strore a file (eg. excel/image) to keep the format, then go for blob.
JanMah
If you want to strore a file (eg. excel/image) to keep the format, then go for blob.
JanMah
ASKER
how exactly can i insert it back into the database? I cant insert a byte()
is there another method i have to do?
is there another method i have to do?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Do you want to convert BLOB to string in oracle itself or in a programming language (VB ..)?