Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problems querying database with Tk / OLE

Status
Not open for further replies.

parkers

Vendor
Oct 21, 2002
157
GB
Hi,

I'm using Tk and OLE to try and get information from an MS Access database ... here is my code...

#
# Summary..
#
# Connect to Access db, perform SQL search
# Print values to a listbox 'widget'
#

my $conn = CreateObject OLE "ADODB.Connection";
my $sql = "SELECT PNPartNumber,PNTitle FROM PN
WHERE PNPartNumber = '$string'";

my $rs = $conn->Execute($sql);
while ( $rs->{EOF} )
{
$return = $rs->Fields(PNPartNumber)->Value." ".$rs->Fields(PNTitle);

$listbox_widget->insert('end',$return);
push (@store, $rs->Fields(PNPartNumber)->Value, $rs->Fields(PNTitle)->Value);
$rs->MoveNext;
}
$rs->Close();


Now on running this section of code I get the following error ...

Tk::Error: Can't call method "Close" on unblessed reference
(command bound to event)

(The event is a <RETURN> key bind from an entry box)

If I remove all Tk code and run as a simple DOS application then I can query the db OK...

Hopefully this is enough information so does anyone have any hints on where I am going wrong or what I could test to resolve?

Thanks,
SP
 
... as normal I figured out the problem just after I submitted this forum post !!!

Anyway I have more problems ... this time doing a multi-table query ...

Here is my code...

$conn = CreateObject OLE "ADODB.Connection";
$conn->Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=my.mdb;");
$sql="SELECT * FROM Tab1, Tab2 WHERE Tab1.id = Tab2.id";
$rs = $conn->Execute($sql);
while (! $rs -> EOF())
{
print "\n",$rs->(Tab1.info1)->Value;
}
$rs->Close;


And the error received is as follows:

Can't call method EOF on an undefined value

If I move the sql statement to a single table query then it works OK ...

If anyone has any ideas I'd really appreciate the help...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top