Hi
I'm hoping someone can help me explain how to fix a problem I have with
reading a Blob field from a SQLite DB using Perl. My long term aim is to
not save it to a file but use it within my application and store it as a
label bitmap. However, first things first.

This code reads the Blob but when I view the bmp file created it is
distorted - as though the bits have been wrapped around and ones I'd
expect on the right are on the left of the image in the prevw. Looking
at the icon in the SQLite DB all is well.

#!/usr/bin/perl -w
use strict;
use DBI;
use Cwd;
use Win32::GUI::BitmapInline ();
our $datafile   = getdcwd()."\\mydatabase.db";

# suck icon from SQLite database, 
my @array;
my $dbh = DBI-> connect("dbi:SQLite:dbname=$datafile","","",{});    #
database handle
my $sql = "SELECT icon FROM icons WHERE name = 'logo'";
my $sth = $dbh-> prepare($sql);                                     #
statement handle

# must have this next line but DONT KNOW WHY
my $numrows = $sth->execute;

open OUTPUT, ">output.bmp";
my $ref = $sth->fetchrow_hashref;
my $newdata = $$ref{'icon'};
print OUTPUT $newdata;
close OUTPUT;

$sth->finish;
undef $sth;
$dbh->disconnect(); 


Q1. Why is the line my $numrows = $sth->execute; essential? If it is not
present I can't view the image file at all and I get a message that
preview is not available.
Q2. How do I fix it so the bmp file displays perfectly?


Thanks
Brian Rowlands
We must accept finite disappointment, but we must never lose infinite
hope.
Martin Luther King Jr. </quotes/k/martinlutherking/>  



Reply via email to