Hello,
I'm trying to read a Blob from Oracle and then write it to an audio
file(.AU). I'm using Visual Studio.Net 2003 (VB). I can't seem to get my
code to work. Will someone take a look at it and tell me what am I doing
wrong. Any help would be appreciated. Thanks
Dim Conn As OracleConnectio n = New OracleConnectio n("data source=XXXX;use r
id=XXXXX;passwo rd=XXXXX")
Dim CMD As OracleCommand = New OracleCommand(" SELECT BlobID, Audio FROM
TblBLOB", Conn)
Dim fs As FileStream
Dim bw As BinaryWriter
Dim bufferSize As integer= 100
Dim outbyte(bufferS ize - 1) As Byte
Dim retval As Long
Dim startIndex As Long = 0
Dim OutPutFile As String = "
' Open the connection and read data into the DataReader.
Conn.Open()
Dim myReader As OracleDataReade r =
CMD.ExecuteRead er(CommandBehav ior.SequentialA ccess)
Do While myReader.Read()
' Get the BlobID.
OutPutFile = myReader.GetVal ue(0)
' Create a file to hold the output.
fs = New FileStream("Ora Blob" & OutPutFile & ".AU", FileMode.OpenOr Create,
FileAccess.Writ e)
bw = New BinaryWriter(fs )
' Reset the starting byte for a new BLOB.
startIndex = 0
' Read bytes into outbyte() and retain the number of bytes returned.
retval = myReader.GetByt es(1, startIndex, outbyte, 0, bufferSize)
' Continue reading and writing while there are bytes beyond the size of the
buffer.
Do While retval = bufferSize
bw.Write(outbyt e)
bw.Flush()
' Reposition the start index to the end of the last buffer and fill the
buffer.
startIndex += bufferSize
retval = myReader.GetByt es(1, startIndex, outbyte, 0, bufferSize)
Loop
' Write the remaining buffer.
bw.Write(outbyt e, 0, retval - 1)
bw.Flush()
' Close the output file.
bw.Close()
fs.Close()
Loop
' Close the reader and the connection.
myReader.Close( )
Conn.Close() 1 2109
Hi,
Try this code to read/write from a blob column
Dim PictureCol As Integer = 0 ' the column # of the BLOB
field
Dim cn As New OleDbConnection
("provider=sqlo ledb;server=loc alhost;user
id=myuser;passw ord=mypassword; initial catalog=NorthWi nd")
Dim cmd As New OleDbCommand("S ELECT Picture FROM
Categories WHERE CategoryName='T est'", cn)
cn.Open()
Dim dr As OleDbDataReader = cmd.ExecuteRead er()
dr.Read()
Dim b(dr.GetBytes(P ictureCol, 0, Nothing, 0,
Integer.MaxValu e) - 1) As Byte
dr.GetBytes(Pic tureCol, 0, b, 0, b.Length)
dr.Close()
cn.Close()
Dim fs As New System.IO.FileS tream(DestFileP ath,
IO.FileMode.Cre ate, IO.FileAccess.W rite)
fs.Write(b, 0, b.Length)
fs.Close()
Regards
Mahesh ChandraMouli
Microsoft .NET MVP|MCAD -----Original Message----- Hello,
I'm trying to read a Blob from Oracle and then write it
to an audiofile(.AU). I'm using Visual Studio.Net 2003 (VB). I
can't seem to get mycode to work. Will someone take a look at it and tell me
what am I doingwrong. Any help would be appreciated. Thanks
Dim Conn As OracleConnectio n = New OracleConnectio n
("data source=XXXX;use rid=XXXXX;passw ord=XXXXX")
Dim CMD As OracleCommand = New OracleCommand(" SELECT
BlobID, Audio FROMTblBLOB", Conn)
Dim fs As FileStream
Dim bw As BinaryWriter
Dim bufferSize As integer= 100
Dim outbyte(bufferS ize - 1) As Byte
Dim retval As Long
Dim startIndex As Long = 0
Dim OutPutFile As String = " ' Open the connection and read data into the DataReader.
Conn.Open()
Dim myReader As OracleDataReade r = CMD.ExecuteRea der(CommandBeha vior.Sequential Access)
Do While myReader.Read()
' Get the BlobID.
OutPutFile = myReader.GetVal ue(0)
' Create a file to hold the output.
fs = New FileStream("Ora Blob" & OutPutFile & ".AU",
FileMode.OpenOr Create,FileAccess.Wri te)
bw = New BinaryWriter(fs )
' Reset the starting byte for a new BLOB.
startIndex = 0
' Read bytes into outbyte() and retain the number of
bytes returned. retval = myReader.GetByt es(1, startIndex, outbyte, 0,
bufferSize)
' Continue reading and writing while there are bytes
beyond the size of thebuffer.
Do While retval = bufferSize
bw.Write(outby te)
bw.Flush()
' Reposition the start index to the end of the last
buffer and fill thebuffer.
startIndex += bufferSize
retval = myReader.GetByt es(1, startIndex, outbyte, 0,
bufferSize) Loop
' Write the remaining buffer.
bw.Write(outby te, 0, retval - 1)
bw.Flush()
' Close the output file.
bw.Close()
fs.Close()
Loop
' Close the reader and the connection.
myReader.Close ()
Conn.Close()
. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Ryan Stewart |
last post by:
I am in extremely urgent need (by tomorrow) of a way to store files in and
retrieve files from an Oracle database using TopLink as an intermediary. I
have the JSPs for it, and it works for small files, but larger ones like
Word documents and Excel Spreadsheets give an error saying that the data is
too large for the field. Can anyone help with this? Our file object has a
fileData field which is an array of bytes which is mapped in TopLink to...
|
by: Ken |
last post by:
Hello,
I'm trying to read a Blob from Oracle and then write it to an audio
file(.AU). I'm using Visual Studio.Net 2003 (VB). I can't seem to get my
code to work. Will someone take a look at it and tell me what am I doing
wrong. Any help would be appreciated. Thanks
Dim Conn As OracleConnection = New OracleConnection("data source=XXXX;user
id=XXXXX;password=XXXXX")
|
by: Ken |
last post by:
Hello,
I'm trying to read a Blob from Oracle and then write it to an audio
file(.AU). I'm using Visual Studio.Net 2003 (VB). I can't seem to get my
code to work. Will someone take a look at it and tell me what am I doing
wrong. Any help would be appreciated. Thanks
Dim Conn As OracleConnection = New OracleConnection("data source=XXXX;user
id=XXXXX;password=XXXXX")
|
by: Ken |
last post by:
Hello,
I'm trying to read a Blob from Oracle and then write it to an audio
file(.AU). I'm using Visual Studio.Net 2003 (VB). I can't seem to get my
code to work. Will someone take a look at it and tell me what am I doing
wrong. Any help would be appreciated. Thanks
Dim Conn As OracleConnection = New OracleConnection("data source=XXXX;user
id=XXXXX;password=XXXXX")
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |