in reply to can't call method 'Sql' on an undefined value

Hi,

terce is correct. Also you should close the connection once you are done with it:

$data->Close();

You may also want to do some error checking:
if ($data->Sql($SQL)) { print "The SQL failed.\nError:" .Error(); } else { print "Sql inserted\n" }

The complete code with the fix pointed out by terce and the above error checking is:

use strict; use Win32::ODBC; my $data = new Win32::ODBC("DSN=SQLServer") or die "Could not open bec ++ause of [$!]"; my $SQL = "SELECT itemNbr, Store_Num FROM sales"; if ($data->Sql($SQL)) { print "The SQL failed.\nError:" .Error(); } else { print "Sql inserted\n" } $data->Close();

N.B. The above code is untested but I'm pretty sure that it works.
If you are unsure of things always read the documentation.
Hope this helps

Martin

Replies are listed 'Best First'.
Re^2: can't call method 'Sql' on an undefined value
by ikegami (Patriarch) on Jun 28, 2005 at 16:24 UTC
    You don't need to call Close explicitly. The destructor calls it.