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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PerlScript Error Help...

Status
Not open for further replies.

Elliott3

Programmer
Sep 5, 2002
347
CA
Hi,
I am a programmer but have never user perl and am working on a messy site. I was hopeing that someone could point me in the right direction with this error Iam getting...

Code:
PerlScript Error error '80004005' 

(in cleanup) Can't call method "Value" on an undefined value 

/careers/resdat/admin/employers.asp, line 52

This is line 52:
Code:
    if ($rst->Fields(0)->Value) {

I am thinking that the recordset object is not getting created correctly... any suggestions on where I might look to figure this out?

They also have this at the top wich I assume is important
Code:
use vars qw($Response $Request $Server $Session);

any/all suggestions would be appreciated.. if I have not been clear enough, please let me know..

CES
 
CES,

Could you post more of the code? What is the $rst object? What does the Fields function do, and what does it return?

It seems like you are calling the function Fields from the object $rst, but it isn't returning an object that has a "Value" method. To give you a better answer I'd need to see the code.

-Nick
 
This is the code... looks like a perl version of ASP..
Code:
<%@Language=PerlScript %>
<!-- #Include File="../env.asp" -->
<%

BEGIN {push @INC, "/usr/david/cw/jrd";}

use ii::template;
use strict;
use vars qw($Response $Request $Server $Session);

if (!$Session->{auth_id}) {
    $Response->Redirect("default.asp");
}

my %t_employers_fieldmap = (
___empselect__ => ""
);

my $curpath =  $main::Server->mappath(
        $main::Request->ServerVariables("PATH_INFO"));
$curpath =~ s%[/\\][^/\\]*$%%;

my $t = new ii::template("$curpath/employers.tem", \%t_employers_fieldmap);

if ($Request->Form("Enter")->Item) {

    if (!$Request->Form("company")->Item) {
        $t->setError("instruction");
    }
    else {	
        $Session->{adm_emp_id} = $Request->Form("company")->Item;	
        $Response->Redirect("emphome.asp");
    }
}
my $empselect;
my $strDSN = "driver={SQL Server};server=" . $ServerName . ";uid=" .
              $DbUser . ";pwd=" . $DbPass . ";database=" . $DbName;

my $strSQL = "exec usp_sel_all_temployer";

my $con1 = $Server->CreateObject ("ADODB.Connection");
$con1->Open($strDSN);

my $rst = $main::Server->CreateObject("ADODB.Recordset");
my $cmd1 = $main::Server->CreateObject("ADODB.Command");
$cmd1->{ActiveConnection} = $con1;
$cmd1->{CommandText} = $strSQL;
$cmd1->{Prepared} = 1;

$rst->Open($cmd1);
while (!$rst->EOF() ) {
    if ($rst->Fields(0)->Value) {
        $empselect .= qq{<option value="} . $rst->Fields(0)->Value . qq{">} . $rst->Fields(1)->Value . "</option>\n";
    }
    $rst->MoveNext();
}
$rst->Close();

$t->replace("___empselect__", $empselect);
#$t->replace("___error__", $ErrMsg);

$t->print();
%>

The site runs Perl scripting inside of ASP... the fields function is the recordset field... let me know is you need more explanation..

CES
 
Some of the pages are using use Win32::ASP; modual for writing ASP like code in Perl... does that help at all?

CES
 
I should have mentioned that the code runs on the current Windows NT Server and we are moving it to a Windows 2003 Server and that is where it is not working...
maybe I am missing some more moduals?? Does that help at all?

CES
 
CES,

Your $rst object is being created here:

my $rst = $main::Server->CreateObject("ADODB.Recordset");

This statement:

$rst->Fields(0)->Value

is malfunctioning because the Fields function (which operates from the Server module) is expected to return an object which contains a method called Value, and isn't. You should have the Server module installed fine because creating a new instance from it hasn't generated any errors. I'd look further into what the Fields function does in that module, what kind of object it returns, etc. You might want to try putting in some print statements to see if the Field function always fails, or it only fails when certain conditions are present. Perhaps the object is being created, but the connection to the server or recordset isn't working.

HTH,

-Nick
 
Can you tellme what the '$main::' is for exactly in the following code:
Code:
my $con1 = $Server->CreateObject ("ADODB.Connection");
$con1->Open($strDSN);

my $rst = $main::Server->CreateObject("ADODB.Recordset");
my $cmd1 = $main::Server->CreateObject("ADODB.Command");
$cmd1->{ActiveConnection} = $con1;

and why it is used for the adodb.connection but not the recordset and command? I assume that the $main is a class that they have possibly created on their own... any suggestions regarding that? maybe set? the thing is that the code works on the NT box but not all of it does on the 2003 box... any ideas?

CES
 
I'm thinking that the '$main::' might be at the root of the problem.. maybe lol

CES
 
I have not yet read the thread in detail but do have error handling on the open of the recordset (asuming this is a file or something)?
 
I am not sure if I understand you correctly... could you clearify that?

CES
 
Take a look at this thread: thread219-879303
Someone else getting same error message who came up with a workaround.
Try changing
if ($rst->Fields(0)->Value) {
to
if (defined($rst->Fields(0))) {


 
Thanks for the suggestion.. unfortunatley for me I still have the problem... I have offered $20 to anyone that can solve this..
Remember this is a migration project and the code does work fine on the Windows NT box but not on the new Windows 2003 box... also it is a newer version of SQL Server... it seems like the data might not be getting retrived

CES
 
CES,

To develop on mikevh's idea, try changing the line:

if ($rst->Fields(0)->Value) {

to

if (defined $rest->Fields(0) && $rst->Fields(0)->Value) {

and see what happens. If it still gives an error post what that error is, and we'll further debug from there.

-Nick
 
Oh, sorry, my mistake... I didn't realize it was supposed to give an error. However, I didn't receive an error from it.

A second before you replied to this I solved my problem!!! I came into this project after the SQL database was copied to the development server and was under the impression that the database was in good shape.

The problem ended up being a permission issue on the stored procedure... I simply reimported the data.

AND ITS WORKING!!!! YAY!!

Thank you for those who put there brain towards this! It is always appreciated!

CES
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top