Jez <[EMAIL PROTECTED]> wrote: > My perl code looks like this; > > use DBI; > use warnings;
You should probably "use strict;" aswell and declare your variables before/when you use them with "my". > #open connection to Access database > $dbh = DBI->connect('dbi:ODBC:Deliveries'); > > #construct SQL statement > $sqlstatement= > "SELECT DestinationAddress,CustomerContactNumber > FROM DeliveryScheule > WHERE DeliveryID = \"6636\"\n"; This is ugly. When you want quotes withing quotes, you should use the qq operator like my $string = qq( Look Ma! No "backslash"! ); In any case, DeliveryID seems to be a number - so unless you're certain it's defined as a string, you should probably get rid of the quotes. > print "SQL:"."\n".$sqlstatement."\n"; Strings with double quotes will do interpolation, so you don't have to piece it together. print "SQL:\n$sqlstatement\n"; > #prepare and execute SQL statement > $sth = $dbh->prepare($sqlstatement); > $sth->execute || > die "Could not execute SQL statement, maybe invalid?"; > > #Put the results in an array > [EMAIL PROTECTED]>fetchrow_array; > ($DestinationAddress,$CustomerContactNumber)=$sth->fetchrow_array; I suggest using the all-in-one commands: if( my $ref = $dbh->fetchall_arrayref( $sqlstatement ) ){ foreach my $r (@$ref){ my($DestinationAddress,$CustomerContactNumber) = @$r; # do something } } else { die "DBI error: " . $dbh->errstr; } > When I take my printed SQL statement (from the print > "SQL:"."\n".$sqlstatement."\n"; line) then Copy and Paste > into MS Access as a SQL query - all is fine - I get my > expected result. What's going on? The Access SQl parser is maybe a bit more forgiving than the SQL parser in the ODBC module? HTH, Thomas -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>