Home » Infrastructure » Windows » How to insert/retrieve a BLOB from VB
How to insert/retrieve a BLOB from VB [message #99676] Thu, 14 February 2002 14:23 Go to next message
Sanjeev Rao
Messages: 1
Registered: February 2002
Junior Member
Hello guys..

I am trying to insert/retrieve a BLOB from VB 6.0 and ASP. Any idea how to do this..
Thanks in advance
sanjeev
Re: How to insert/retrieve a BLOB from VB [message #99714 is a reply to message #99676] Wed, 27 February 2002 19:44 Go to previous messageGo to next message
meena
Messages: 36
Registered: December 2000
Member
I too need to solve the same pbm
U can insert into BLOB by using OLE in VB
but can't retrieve BLOB
if u get answer pls inform me
thank U
Re: How to retrieve an Oracle BLOB from Java [message #99818 is a reply to message #99676] Thu, 11 April 2002 13:31 Go to previous messageGo to next message
German
Messages: 1
Registered: April 2002
Junior Member
I canīt retreive an Oracle Blob from JAVA.

The problem is, when I do...executeQuery("select * from table"); oracle returns a General Error.
I canīt retrieve a Blob. But I had no problem with other things like varchar2 or numbers.

All the examples in the net are the same,... with the same problem. How can I fix it ?
How to insert image [message #100042 is a reply to message #99676] Wed, 26 June 2002 06:02 Go to previous messageGo to next message
siva
Messages: 58
Registered: August 1999
Member
I would like to know how to insert images to db
Plz reply soon.
Re: How to insert/retrieve a BLOB from VB [message #100097 is a reply to message #99676] Thu, 18 July 2002 06:10 Go to previous messageGo to next message
Art
Messages: 6
Registered: July 2002
Junior Member
http://odbc.postgresql.org/psqlodbc.php?DocID=howto-vblo

May help????
Re: How to insert/retrieve a BLOB from VB [message #100401 is a reply to message #100097] Tue, 10 December 2002 23:00 Go to previous messageGo to next message
kumaran
Messages: 1
Registered: December 2002
Junior Member
please send me some sample coding for insert/retrive a blob from vb
Re: How to insert/retrieve a BLOB from VB [message #100542 is a reply to message #100401] Tue, 11 February 2003 00:22 Go to previous messageGo to next message
Praveen
Messages: 57
Registered: November 2001
Member
Please send the details blob with vb on insert / retrieval
Re: How to insert/retrieve a BLOB from VB [message #101058 is a reply to message #99714] Fri, 09 April 2004 01:42 Go to previous messageGo to next message
Tariq Khan
Messages: 2
Registered: April 2004
Junior Member
Private Sub cmdSaveBLOBToFile_Click()

' ******************************************************************
' *** This event will take a BLOB that has already been inserted ***
' *** into the database and save it as a file. ***
' ******************************************************************

On Error GoTo ErrorHandler

Screen.MousePointer = vbHourglass

Set cn = New ADODB.Connection

If ConnectivityMethod = "ODBC" Then
' ODBC Connection Setup

Set cn = New ADODB.Connection
With cn
.ConnectionString = ODBCConnectString
.Open
End With

Else
' OLEDB Provider Connection Setup

cn.Provider = "OraOLEDB.Oracle"
cn.ConnectionString = OLEDBConnectString
cn.Open

End If

Set rs = New ADODB.Recordset

' 'blobtest.txt' is the name of a BINARY file that has been stored in the
LOB_TABLE in the database
rs.Open "Select * from LOB_TABLE where FIELD = '" & BlobFileName & "'",
cn, adOpenKeyset, adLockOptimistic

' Create ADO stream object
Set mStream = New ADODB.Stream

' Set it to a binary file type
mStream.Type = adTypeBinary

' Open it
mStream.Open

' This writes the image from the blob field to the buffer
mStream.Write rs.Fields("BLOBFIELD").Value

' This saves the stream to a file on disk
mStream.SaveToFile BlobDestPath & rs.Fields("FIELD").Value

mStream.Close
Set mStream = Nothing

rs.Close
Set rs = Nothing

cn.Close
Set cn = Nothing

Screen.MousePointer = vbDefault

MsgBox "Blob saved to file as " & BlobDestPath & BlobFileName, , "Blob
Saved"

Exit Sub

ErrorHandler:

Screen.MousePointer = vbDefault

Select Case Err.Number
Case 3004
MsgBox "Could not write file.", , "File Already Exists"
Case Else
MsgBox Err.Number & " - " & Err.Description, , "Error Msg"
End Select

End Sub

- - - - - - - - - - - - - - - - Code ends
here - - - - - - - - - - - - - - - -

Sample Output
-------------

Message boxes confirming the upload and retrieval of the LOBs will be
displayed and any LOB's retrieved from the Oracle database will be stored
into the 'C:Temp' folder on your computer.
Re: How to insert/retrieve a BLOB from VB [message #101059 is a reply to message #101058] Fri, 09 April 2004 01:45 Go to previous messageGo to next message
Tariq Khan
Messages: 2
Registered: April 2004
Junior Member
Private Sub cmdSaveBLOBToDB_Click()

' *******************************************************************
' *** This event will insert a BLOB from a file into the database ***
' *******************************************************************

On Error GoTo ErrorHandler

Screen.MousePointer = vbHourglass

Set cn = New ADODB.Connection

If ConnectivityMethod = "ODBC" Then
' ODBC Connection Setup

Set cn = New ADODB.Connection
With cn
.ConnectionString = ODBCConnectString
.Open
End With

Else
' OLEDB Provider Connection Setup

cn.Provider = "OraOLEDB.Oracle"
cn.ConnectionString = OLEDBConnectString
cn.Open

End If

Set rs = New ADODB.Recordset

rs.Open "Select * from LOB_TABLE", cn, adOpenKeyset, adLockOptimistic

' Create the ADO Stream object
Set mStream = New ADODB.Stream

' Make it a binary type
mStream.Type = adTypeBinary

' Open the stream
mStream.Open

' Read the binary file into the stream buffer
mStream.LoadFromFile BlobSourcePath & BlobFileName

' Add the blob to the database
With rs
.AddNew
.Fields("BLOBFIELD").Value = mStream.Read
.Fields("FIELD").Value = BlobFileName
.Update
End With

mStream.Close
Set mStream = Nothing

rs.Close
Set rs = Nothing

cn.Close
Set cn = Nothing

Screen.MousePointer = vbDefault

MsgBox "Blob inserted into DB from " & BlobSourcePath & BlobFileName, ,
"Blob Inserted"

Exit Sub

ErrorHandler:

Screen.MousePointer = vbDefault

Select Case Err.Number
Case 3002
MsgBox "Could not read file, check the path.", , "File Not Found"
Case Else
MsgBox Err.Number & " - " & Err.Description, , "Error Msg"
End Select

End Sub
Re: How to retrieve an Oracle BLOB from Java [message #198535 is a reply to message #99818] Tue, 17 October 2006 09:20 Go to previous message
nix5402
Messages: 1
Registered: October 2006
Location: New Hampshire
Junior Member
In response to the problem:

-----
"when I do...executeQuery("select * from table"); oracle returns a General Error."
------

Answer:

I suggest that you contact Oracle to verify
that you are using the correct string for connecting to the
database. I was getting a similar error because unknown to
me my connection string was specifying a non-oracle driver.
The connection method that worked for me is:

Class.forName( "oracle.jdbc.OracleDriver");

Connection my_conn = DriverManager.GetConnection (
"jdbc:oracle:thin:@bmds14:1521:bmds",
userName, Password);

where

"bmdsrv14" is the name of my Oracle server,
"1521" is the port number on the Oracle server, and
"bmds" is my sid.

Please let me know if this solves your problem.


Previous Topic: Oracle 9.2 Installation Problem
Next Topic: Executing multi-line sql commands via ADO/Oracle drivers
Goto Forum:
  


Current Time: Fri Mar 29 09:18:39 CDT 2024