I'm trying to return recordsets from predefined parameterised queries in MS
Access. I've read all the posts, checked my code, but try as I might I can't
get a
parameter query to return me a recordset. What am I doing wrong?
The following code fails with "Can't call method "EOF" on an undefined value" -
on the marked line. In other words the recordset has not been created.
John Wilson
Youth would be an ideal state if it came a little later in life.
~Herbert Henry Asquith
#------------------------------------------------------------------
use Win32::OLE;
$Conn = Win32::OLE->new( "ADODB.Connection");
$cm = Win32::OLE->new( "ADODB.Command");
$RS = Win32::OLE->new( "ADODB.RecordSet");
$Conn->Open('Northwind'); # or die "Cannot connect";
$qryCity = 'seattle';
# stored proc text :
# PARAMETERS pCity Text ( 255 );
# SELECT *
# FROM employees
# WHERE city = pCity;
$cm->{ActiveConnection} = $Conn;
$cm->{CommandType} = adCmdStoredProc;
$cm->{CommandText} = 'spEmployeeInCity';
$cm->Parameters->Append($cm->CreateParameter('pCity', adChar, adParamInput, 25,
$qryCity));
# V---------- fails on this line ----------------------
$RS = $cm->Execute();
while(!$RS->EOF) {
$lastname = $RS->Fields('LastName')->Value;
$firstname = $RS->Fields('FirstName')->Value;
print "$lastname, $firstname\n" ; # print them out
$RS->MoveNext();
}
$cm-Close;
$RS->Close;
$Conn->Close;
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs