[EMAIL PROTECTED] wrote:

Hello all, Sometimes it is just more sensible to find a workaround rather than a solution. So, here is an updated script that uses DBI::ADO to create the database, DBI::ODBC to populate and test it, and DBI::ADO to retrieve the pics via CGI. Thanks for the pointer, Bart! As before, the pics I used are available at http://geocities.com/amonotod/picsDB_images.zip. Populate the database with "perl myPics.pl load=1", then view the script via a browser and web server of choice.... And, again, thanks for DBI, DBI::ADO, DBI::ADO, DBI::Sybase, DBI::Oracle and all the other great modules that are supported by this group... Steffen, perhaps you could look at the difference in the bind variable code between DBD::ADO and DBD::ODBC? I'd offer, but my ability with C es even more pitiable than with Perl...

Thanks, but ODBC and ADO are quite different beasts. I further investigated your
test case: the Jet ADO provider creates for the LONGBINARY column a parameter of
type 202 (adVarWChar) and size 510 - both are wrong. Thus, it's necessary to set
the type in bind_param() - which you did. However, DBD::ADO did not set the 
size.
Attached is a fixed implementation for bind_param(). It would be nice if you 
(and
others) give it a trial.


Steffen
  sub bind_param {
    my ( $sth, $n, $value, $attr ) = @_;
    my $conn = $sth->{ado_conn};
    my $comm = $sth->{ado_comm};

    $attr = {} unless defined $attr;
    $attr = { TYPE => $attr } unless ref $attr;

    my $param_cnt = $sth->FETCH('NUM_OF_PARAMS') || _refresh( $sth );

    return $sth->set_err( -915,"Bind Parameter $n outside current range of 
$param_cnt.") if $n > $param_cnt || $n < 1;

    $sth->{ParamValues}{$n} = $value;

    my $i = $comm->Parameters->Item( $n - 1 );

    if ( exists $attr->{ado_type} ) {
      $i->{Type} = $attr->{ado_type};
    }
    elsif ( exists $attr->{TYPE} ) {
      $i->{Type} = $DBD::ADO::TypeInfo::dbi2ado->{$attr->{TYPE}};
    }
    if ( defined $value ) {
      $i->{Size}  = defined $attr->{ado_size} ? $attr->{ado_size} : length 
$value;
      if ( $i->{Type} == $Enums->{DataTypeEnum}{adVarBinary}
        || $i->{Type} == $Enums->{DataTypeEnum}{adLongVarBinary}
         ) {
        my $pic = Win32::OLE::Variant->new( Win32::OLE::Variant::VT_UI1() | 
Win32::OLE::Variant::VT_ARRAY(), $i->{Size} );
        $pic->Put( $value );
        $i->{Value} = $pic;
        $sth->trace_msg("    -- Binary: $i->{Type} $i->{Size}\n", 5 );
      }
      else {
        $i->{Value} = $value;
        $sth->trace_msg("    -- Type  : $i->{Type} $i->{Size}\n", 5 );
      }
    }
    else {
      $i->{Value} = Win32::OLE::Variant->new( Win32::OLE::Variant::VT_NULL() );
    }
    return 1;
  }

Reply via email to