Jim,

Out of curiousity (as I've been in a patching frenzy lately) what doesn't
work with DBD::ODBC that does with DBD::ADO?  I would have thought that BOTH
would be relatively similar in behavior.

Jeff

> -----Original Message-----
> From: Jim Clark [mailto:[EMAIL PROTECTED]]
> Sent: Friday, February 01, 2002 7:47 PM
> To: Simon Oliver
> Cc: [EMAIL PROTECTED]; Jeff Urlwin
> Subject: Re: Inserting binary data into OLE fields in MS Access 2000
>
>
> Switching the SQL queries back to use an OLE field instead of a
> memo field fixed
> the problem and worked. Found a word of warning on MSDN at
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/d
> ao360/html/damthgetchunk.asp
> that basically warns to keep binary data in OLE fields and text
> in memo fields.
> Mixing the two 'will cause undesirable results'.
>
> It's funny how DBD:ADO has worked in the past where DBD:ODBC
> doesn't and vice
> versa. Thanks to both you and Jeff for pointing me to DBD:ODBC.
>
> -Jim
>
> Jim Clark wrote:
>
> > Thanks. The insert is now working with a memo field but I came
> across something
> > else that leaves me puzzled.
> >
> > After the insert, a select pulls the data out just to confirm
> the data was
> > inserted correctly. Problem is that when using
> SQL_LONGVARBINARY and a jpeg
> > file, what is returned is exactly half of what went in. Switching to
> > SQL_LONGVARCHAR and a simple text file, the ouput matched the
> input exactly.
> >
> > -Jim
> >
> > use DBI qw(:sql_types);
> > my $imagedata;
> > my $title = "Test run 1";    # change this to make sure both
> insert and fetch
> > use same record
> > undef $/;
> >
> > open(FILE,'C:\temp\test.jpg');   # switch here for different file type
> > binmode FILE;
> > $imagedata = <FILE>;
> > close(FILE);
> >
> > print "Insert Length: " . length ($imagedata) . "\n";
> >
> > $dbh = DBI->connect("dbi:ODBC:mydatabase", "user", "password")
> or die "Database
> > connection not made: $DBI::errstr";
> > $dbh->{LongReadLen} = 64000;
> > #$dbh->{LongReadTruncOK} = 0;
> >
> > $sth =  $dbh->prepare( "INSERT INTO images (Product_ID,
> ImageMemo, Title)
> > VALUES (101, ?,  '$title')" );
> > $sth->bind_param( 1, $imagedata, SQL_LONGVARBINARY );
> > $sth->execute();
> >
> > #print $imagedata if defined $imagedata;
> >
> > # Fetches data from DB. Should be same length as what was just inserted
> >
> > undef $imagedata;
> >
> > $sth =  $dbh->prepare( "Select ImageMemo From images Where
> Title = '$title'" );
> >
> > $sth->execute();
> > $sth->bind_col( 1, \$imagedata, { type => SQL_LONGVARBINARY } );
> > $sth->fetch;
> >
> > print "Fetch Length: " . length ($imagedata) . "\n";
> > #print $imagedata if defined $imagedata;
> >
> > $sth->finish;
> > $dbh->disconnect;
> >
> > ---------------
> >
> > D:\Webroot\cgi-bin>perl saveimage.cgi
> > Insert Length: 62082
> > Fetch Length: 31041
>
>

Reply via email to