Dear Fellow Monks,

I am stumped regarding an issue with the WIN32:ODBC module and a Micros~1 Access Database.

Comming from a completely Un*x-y background, I have found a need to use the WIN32:ODBC driver to connect to a Windows Access database via Perl CGI. I have done this before with an already existing Access database. But now I need to use a DNS-less connection, as well as an Access database I made myself. I created a database using Access and uploaded it to my server. I then used the code below to connect to the database. I didn't get a connection error. However, when I tried to call any methods on my "$db" object, I get errors. What do I have to do to successfully connect? Do I have to save my Access database in some special way? Does any Monk know where I can go to read more about this, I can't find a good reference anywhere!

My code looks like this:
# Load necessary modules use Win32::ODBC; use CGI; use CGI::Carp qw(fatalsToBrowser); # DNS related Variables... $username = "foo"; $password = "bar"; $database_path = "name_of_my_database.mdb"; #create database object called $db... $db = new Win32::ODBC("DNS=$database_path;UID=$username;PWD=$password" +); # These lines do not give me an error... # Doesn't this mean I have a proper connection? if (undef $db){ Win32::ODBC::DumpError(); } # This line gives me an error which says something # like Can't call method "Connection" on undefined # value... $con_number = $db->Connection;
Thanks Monks!

In reply to WIN32:ODBC Perl Connection to Micros~1 Access Database by mr_dont

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.