|
I had several mdb files that required the same update to one field. So I use the following is a snippet of the code I was using.
my $sql = "update [Contact] set Contact.Source ='BioCRM'"; my $sth = $dbh->prepare($sql) or die( "Can't prepare SQL statement. Perl + says $!, DBI says ". $dbh->errstr. "\n"); $sth->execute($sql) or die "Couldn't execute statement: " . $sth->errstr;
Kept getting the following error
DBD::ADO::st execute failed: Bind Parameter 1 outside current range of 0. at Z:\UpdateAllContactSource.pl line 33, <> line 1. Couldn't execute statement: Bind Parameter 1 outside current range of 0. at Z:\UpdateAllContactSource.pl line 33, <> line 1.
At first I searched the Internet for a solution, I updated all my DBD drivers and it still did not work. It is funny the number of articles you can find when you search for DBD::ADO::st execute failed:
488 on Google.
None of them helped. My error is in this line:
$sth->execute($sql) or die "Couldn't execute statement: " . $sth->errstr;
When execute is used in this way it does not take any parameters
The fix
$sth->execute() or die "Couldn't execute statement: " . $sth->errstr;
Hope this helps someone else
If not try using the do syntax for updates and inserts
$dbh->do($sql) or die( "Can't execute SQL statement. Perl + says $!, DBI says ", $DBI::errstr, "\n" );
Keep Coding
-
Jeremy
|