Thread: large objects, visual basic, ADO

large objects, visual basic, ADO

From
Tulassay Zsolt
Date:
(I've posted this once before, but it didn't make it to the list
I hope this time it will work)

hi,
I tried the combination of the above three (for now only for reading)
but did not succeed. I searched the mailing list archives, but did not
find any appropriate solution, so if anybody out there ever saw this
working please drop me a line on how to do it.

I use PostgreSQL 7.1-RC4 (I know, I know), some recent 7.x ODBC driver,
and VB6 on the client side with ADO 2.0
I have a table called lo1 which looks like this:
zsolt=# \d lo1
                 Table "lo1"
 Attribute |         Type          | Modifier
-----------+-----------------------+----------
 name      | character varying(32) |
 image     | oid                   |

I tried to fetch the data from pg_largeobject and write it to a file on
the client using the following VB code:

  rs.Open "select * from pg_largeobject where loid=(select image _
           from lo1 where name='tilos') ORDER BY pageno", env1.conn1
  Open "C:\zsolt\t1.bmp" For Binary Access Write As #1
  rs.MoveFirst
  Do While Not rs.EOF
>   varChunk = rs.Fields(2)
    Put #1, , varChunk
    rs.MoveNext
  Loop
  Close #1
  rs.Close


The problem seems to be in the line marked with ">".
As it seems for me, the size of the data chunks in pg_largeobject is 2048
bytes. But in the code above only the first 254 bytes are "visible"
through the ADO interface. The first 254 bytes do get transferred
correctly, but the rest is lost, so the file I get in the end is about 1/8
the size of the original (actually a bit more, but I didn't check the
contents byte by byte, just the beginning of each file)

Any help/solution would be greatly appreciated (I don't care if it's RDO
or whatever)

Thanks,
Zsolt Tulassay



Re: [ODBC] large objects, visual basic, ADO

From
Hiroshi Inoue
Date:
Tulassay Zsolt wrote:
>
> (I've posted this once before, but it didn't make it to the list
> I hope this time it will work)
>
> hi,
> I tried the combination of the above three (for now only for reading)
> but did not succeed. I searched the mailing list archives, but did not
> find any appropriate solution, so if anybody out there ever saw this
> working please drop me a line on how to do it.
>

You need the type 'lo' to use large objects from ODBC.
See contrib/lo or go to a mirror ftp site and see
odbc/faq.html(Can I use large objects or OLE ?).

regards,
Hiroshi Inoue