Hello all,
In Feb, 2002, I was attempting to migrate some flat file tables into Access. I had
significant difficulty wandering through the maze of DB modules and their use in perl,
and moved on to other projects. Now I'm looking at this again.
At that time, I asked a question about creating and using DSNs for Access and received
the following code sample from Simon Oliver --
#!/usr/bin/perl
# program: soliver1.pl
use warnings;
use strict;
use Win32::ODBC;
my $option = ODBC_ADD_SYS_DSN;
my $driver = 'Microsoft Access Driver (*.mdb)';
my $dsn = 'Test_DSN';
my $dbf = 'c:\test.mdb';
my $conn = new Win32::ODBC()
or print "Error creating ODBC object";
Win32::ODBC::ConfigDSN ( $option, $driver, 'DSN=$dsn', 'CREAT_DB=$dbf' )
or print "Error creating DSN '$dsn'.\n";
print Win32::ODBC::Error();
$conn = new Win32::ODBC($dsn)
or print "Error opening DSN '$dsn'.\n";
print Win32::ODBC::Error();
my $sql = 'CREATE TABLE test_table (id int, name varchar(32))';
my $rv = $conn->Sql($sql);
warn $rv;
my @tables = $conn->TableList('','','','');
print join(',', @tables), "\n";
$conn->Close;
My first chance to test this was today. When I run it, I receive the following errors
--
Use of uninitialized value in subroutine entry at C:/Perl/site/lib/Win32/ODBC.pm
line 107.
Error creating ODBC object911[Microsoft][ODBC Driver Manager] Data source name n
ot found and no default driver specifiedUse of uninitialized value in print at s
oliver1.pl line 20.
Error opening DSN 'Test_DSN'.
911[Microsoft][ODBC Driver Manager] Data source name not found and no default dr
iver specifiedUse of uninitialized value in print at soliver1.pl line 25.
Can't call method "Sql" on an undefined value at soliver1.pl line 29.
In the code for Win32::ODBC, it seems as though the sub at line 107 is expecting a
passed parameter of some sort. Can someone clue me in as to why this doesn't work?
Glen