Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

copying images using ado

3 views
Skip to first unread message

shawn carter

unread,
Jan 23, 2002, 2:34:02 PM1/23/02
to
Hi

I am trying to copy an image from an oracle database to
another record with the the same database I have tried to
use the appendChunk method but have not been to
successful. The that I am receiving is "run time
error '3251':
Object or provider is not capable of performing requested
operations". Can anyone help an example code is below.


Sub ReadToBinary(ByVal F As Long, fld As ADODB.Field, _
ByVal FileSize As Long)
Dim Data() As Byte, BytesRead As Long
Do While FileSize <> BytesRead
If FileSize - BytesRead < BLOCK_SIZE Then
Data = InputB(FileSize - BytesRead, F)
BytesRead = FileSize
Else
Data = InputB(BLOCK_SIZE, F)
BytesRead = BytesRead + BLOCK_SIZE
End If
fld.AppendChunk Data
Loop
End Sub

Val Mazur

unread,
Jan 23, 2002, 3:01:37 PM1/23/02
to
Hi,

I think in your case you can avoid using ADO. Just use
INSERT SQL statement to insert data from one table to
another one. You do not need retrieve records to client
side to provide that, you can do that just in one SQL
statement on server

Val

>.
>

shawn carter

unread,
Jan 23, 2002, 4:50:53 PM1/23/02
to
Val

Thanks for the quick reply. I tried what you were talking
about and I get an error invalid use on Long datatype.
The column is a Long Raw. Oracle doesnt like it when move
long data around without doing something special first.
But anyways any thoughts on why I can not read a image
into the oracle database by using appendChunk.

Thanks

>.
>

Val Mazur

unread,
Jan 24, 2002, 7:32:09 AM1/24/02
to
Hi,

Try to use Stream object to load field with binary data.
Here is an example. It uses Acces, but works with SQL
Server as well

Dim loConnection As ADODB.Connection
Dim loRecordset As ADODB.Recordset
Dim loStream As ADODB.Stream

Set loConnection = New ADODB.Connection
Set loRecordset = New ADODB.Recordset
loConnection.Open "Driver={Microsoft Access Driver
(*.mdb)};" & _
"Dbq=" & App.Path & "\Reports.mdb;" & _
"Uid=Admin;" & _
"Pwd=;"

loRecordset.Open "SELECT Field1, ImageField FROM tblTable1
WHERE Field1='F4'", loConnection, adOpenKeyset,
adLockOptimistic, adCmdText
Set loStream = New ADODB.Stream

loStream.Open
loStream.Type = adTypeBinary
loStream.LoadFromFile App.Path & "\TopTab.gif"
loStream.Position = 0
loRecordset.AddNew
loRecordset.Fields("Field1").Value = "F4"
loRecordset.Fields("ImageField").AppendChunk loStream.Read
loRecordset.Update

loStream.Close
loRecordset.Close
loConnection.Close
Set loStream = Nothing
Set loRecordset = Nothing
Set loConnection = Nothing

Val

>.
>

0 new messages