' The ADO Connection Object is used to create an open ...



' The ADO Connection Object is used to create an open connection to a data source. Through this connection, you can access and manipulate a database.

' Only windows

Set adoConexao = CreateObject("ADODB.Connection") adoConexao.ConnectionString = "provider=OraOLEDB.Oracle;Data Source=;User Id=;Password=;PLSQLRSet=1"

adoConexao.Open

' adStateOpen

' The object is open

adStateOpen = 1

If ( adoConexao.state = adStateOpen ) Then

' select from ORACLE - IMG_FIELD is an BLOB field

SQL = "SELECT IMG_FIELD FROM TABLE WHERE SEQUENCE="

' The ADO Recordset object is used to hold a set of records from a database table. A Recordset object consist of records and columns (fields).

' This doesn´t work with Lotus ODBC class, so we need use a ADODB RecordSet

Set adoRecordset = CreateObject("ADODB.RecordSet")

adoRecordset.Open SQL, adoConexao

If Not ( adoRecordset.EOF ) Then

' The ADO Stream Object is used to read, write, and manage a stream of binary data or text.

' adSaveCreateOverWrite

' Overwrites the file with the data from the currently open Stream object, if the file already exists

adSaveCreateOverWrite = 2

' adTypeBinary

' Binary data

adTypeBinary = 1

Set adoStream = CreateObject("ADODB.Stream")

With adoStream

.Type = adTypeBinary

.Open

.Write adoRecordset.Fields("IMG_FIELD").value

.SaveToFile "C:Temp.jpg", adSaveCreateOverWrite ' path of image

.Close

End With

Set adoStream = Nothing

Set adoRecordset = Nothing

Set adoConexao = Nothing

End If

End If

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download