You must specify that this is a number instead it binds it as a string by
default.  Try this...

$dbh = DBI->connect("dbi:ODBC:myDSN",'','');
$sql = "Select * From myTable Where ID_Code = ?";
$sth = $dbh->prepare($sql);
$sth->bind_param(1, $ID_code, SQL_INTEGER);
$sth->execute();  #ID_code contains ID_Code value


Ilya Sterin


-----Original Message-----
From: Krung   Saengpole
To: [EMAIL PROTECTED]
Sent: 06/13/2001 3:07 PM
Subject: SQL statement.

Hi all,

I have one problem that should not be. I use Access97 on NT server with
IIS5. I couldn't use placeholder in SQL statement as below:

use DBI;
$dbh = DBI->connect("dbi:ODBC:myDSN",'','');
$sql = "Select * From myTable Where ID_Code = ?";
$sth = $dbh->prepare($sql);
...
$sth->execute($ID_code);  #ID_code contains ID_Code value
$rc = $sth->fetchrow_hashref;
print $rc->{'FIELD_NAME'}; # no result

I have to change $sql to "Select * From myTable Where ID_Code=$ID_code"
and call $sth->execute() instead to fetch the result to $rc. What's
wrong with my code?

Any advices would be greatly appreciated.
Krung.

Reply via email to