talanki has asked for the wisdom of the Perl Monks concerning the following question:

When i execute the following code on Windows 2000 it works without error, but on Windows XP, it generate the error "Can't call method "SqL" on an undefined value"
my $db = new Win32::ODBC("dsn=A3T;UID=shenriks;PWD=changeme0"); $db->Sql("SELECT SIM_SERIAL_NBR FROM PHYS_EQP WHERE IMSI='310380007269 +591'"); $db->Sql($SqlStatement); $db->FetchRow(); $SIM = $db->Data("SIM_SERIAL_NBR");
Please provide why it is not working on XP. I appreciate your help.

Edit by castaway - added code tags

  • Comment on WIn32::ODBC - Can't call method "SqL" on an undefined value on XP machine
  • Download Code

Replies are listed 'Best First'.
Re: WIn32::ODBC - Can't call method "SqL" on an undefined value on XP machine
by jimbojones (Friar) on Apr 06, 2005 at 21:38 UTC
    Hi

    I suspect that you aren't connecting to the dsn correctly from your XP box. Hence, after the first line, the object $db is undefined. Something like:

    my $db = new Win32::ODBC("dsn=A3T;UID=shenriks;PWD=changeme0"); die "Cannot connect to dsn A3T" unless ( defined $db );
    or something like that. From the Win32::ODBC doc
    ...

    Next, create a data connection to your DSN:

    $Data = new Win32::ODBC("MyDSN");
    NOTE: MyDSN can be either the DSN as defined in the ODBC Administrator, or it can be an honest-to-God DSN Connect String.

    Example: "DSN=My Database;UID=Brown Cow;PWD=Moo;"

    You should check to see if $Data is indeed defined, otherwise there has been an error.
    (emphasis added).

    Also, look into code tags for your posts. See this node 17558 for more details.

    Updated: added link to writeup formatting node

    - j

Re: WIn32::ODBC - Can't call method "SqL" on an undefined value on XP machine
by simon.proctor (Vicar) on Apr 06, 2005 at 23:11 UTC
    From my experience, in addition to the above node you should check that your DSN exists on the system. I have a web app using a similar connection method and I have my DSN setup as as system DSN and it works fine.

    You mention that it works on Win2K but not XP indicating (to me) separate machines/systems that may not be setup identically.

    I would consider start there.