Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^6: Perl CGI and SQL statements

by osunderdog (Deacon)
on Apr 19, 2006 at 13:44 UTC ( [id://544354]=note: print w/replies, xml ) Need Help??


in reply to Re^5: Perl CGI and SQL statements
in thread Perl CGI and SQL statements

my $db = new Win32::ODBC('$DSN');

Firstly, you need to either remove the tic marks or use double quotes. The way this is written, you're sending exactly $DSN as a string. If you want to send what $DSN is set to, then use: my $db = new Win32::ODBC($DSN);

Secondly, this probably explains the next problem... $db is undefined because the instance creation failed. In other words, after you do this:

my $db = new Win32::ODBC($DSN);

You should check $db to verify that the object was created successfuly. If it could not connect, then $db will be undefined. The error you are seeing is because you can't call the function Sql on an undefined $db variable.

Seriously, a little time with the perl debugger, now that you've got compilable code, would help you understand what's going on.

Neat Debugger tricks

Re: Linux vs. Windows for Learning Perl

perl debugger

Hazah! I'm Employed!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://544354]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2024-07-24 22:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.