Hi. I've looked everywhere and tried an enourmous amount of different syntaxes for this, but I keep getting an error when trying to search my database table using a date.
I've tried using ' ' around the date, I've tried using # # around the date, I've tried change the format (dd-mm-yyyy, mm-dd-yyyy). I've tried using / instead of - and nothing seems to work. I get this error message when running:
DBD::ODBC::st execute failed: [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1. (SQL-07002?)(DBD: st_execute/SQLExecute err=-1) .
Any help would be greatly appreciated.
Code:
use DBI;
my $dbh;
sub initialise {
#open connection to Access database
$dbh = DBI->connect("dbi:ODBC:TheatreWol", {AutoCommit => 1}) || die "Couldn't connect to DB\n";
}
initialise();
print "Enter command (search, quit): ";
$opt = <STDIN>;
chomp($opt);
while ($opt ne "quit") {
if ($opt ne "search") {
print "Invalid option - (search, quit):";
$opt = <STDIN>;
chomp($opt);
next;
}
#prepare and execute SQL statement
$sqlstatement="SELECT * FROM TheatreWol2007Presentations WHERE startdate=2007-02-01";
$sth = $dbh->prepare($sqlstatement);
$sth->execute || die "Could not execute SQL statement ... maybe invalid?";
#output database results
while (@row=$sth->fetchrow_array)
{ print "@row\n" }
print "Enter command (search, quit): ";
$opt = <STDIN>;
chomp($opt);
}
DBD::ODBC::st execute failed: [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1. (SQL-07002?)(DBD: st_execute/SQLExecute err=-1) .
Any help would be greatly appreciated.
Comment