Jim,

You can try DBD::ODBC.  I don't think you'll have an issue, but let me know
if you do.

Jeff

> -----Original Message-----
> From: Jim Clark [mailto:[EMAIL PROTECTED]]
> Sent: Friday, February 01, 2002 4:34 AM
> To: [EMAIL PROTECTED]
> Subject: Inserting binary data into OLE fields in MS Access 2000
>
>
> Hello,
>
> I'm trying to insert image data into an OLE field in MS Access database
> without success. I treat the image as a long binary field so if a 10k
> jpeg file is inserted, it remains at 10k in the database... not the
> bloated several hundred k or more that doing an 'insert object' produces
> within Access. Eventually, these images are to be served from the
> database to support a web site. Since the database is replicated, the
> image data needs to be in the database and not filenames pointing to
> where the images may be in the directory structure.
>
> I'm following the DBI code in the Cheetah book p. 153 and have
> substituted the various type parameters (p. 147) including all the
> SQL_BINARY, SQL_VARBINARY and SQL_LONGVARBINARY constants. If in the
> code below, I remove from the SQL the Image field and its placeholder /
> bind, the query works.
>
> Any pointers would be appreciated.
>
> -Jim
>
> Perl build 629, DBI::ADO 2.4, MDAC 2.6, Access 2000, WinXP
>
> #!c:/perl/bin/perl.exe -w
> use DBI;
>
> open(FILE,'C:\temp\test.jpg'); # 5K test file so buffers / truncating
> should not be an issue
> undef $/;
> $imagedata = <FILE>;
> close(FILE);
>
> $dbh = DBI->connect("dbi:ADO:mydatabase", "user", "password") or die
> "Database connection not made: $DBI::errstr";
>
> $sth =  $dbh->prepare( "INSERT INTO images (Product_ID, Image, Title)
> VALUES (1012334844,  ? , 'New Title')" );
> $sth->bind_param( 1, $imagedata, SQL_BINARY );
> $sth->execute();
> $sth->finish;
> $dbh->disconnect;
>
>
> D:\Webroot\cgi-bin>perl saveimage.cgi
> DBD::ADO::st execute failed: Can't execute statement 'INSERT INTO images
> (Image)
>  VALUES ( ? )':
> Lasterror:       -2147217887: OLE exception from "Microsoft OLE DB
> Provider for
> ODBC Drivers":
>
> [Microsoft][ODBC Microsoft Access Driver]Invalid precision value
>
> Win32::OLE(0.1501) error 0x80040e21
>     in METHOD/PROPERTYGET "Open"
>         Description:    [Microsoft][ODBC Microsoft Access Driver]Invalid
> precisi
> on value
>         HelpContext:    0
>         HelpFile:
>         NativeError:    98
>         Number:         -2147217887
>         Source:         Microsoft OLE DB Provider for ODBC Drivers
>         SQLState:       S1104 at saveimage.cgi line 13.
>
>
>
>

Reply via email to