You should just be able to use

my $DSN = 'driver=Microsoft Access Driver(*.mdb);dbq=C:/dyc/dyc.mdb';

I had some problems with that when trying to use Win32::ODBC with a Access database. What I ended up doing was writing a file DSN on the fly, then cleaning it up on exit. That seemed to work a little better for me. It was something like this:

# Create the MS Access DSN my $dsncontents = <<"EODSN"; [ODBC] DRIVER=Microsoft Access Driver (*.mdb) UID=admin UserCommitSync=Yes Threads=3 SafeTransactions=0 PageTimeout=5 MaxScanRows=8 MaxBufferSize=2048 FIL=MS Access DriverId=25 DefaultDir=$datadir DBQ=$file EODSN open(DSN, ">$datadir/Report.dsn") or die "Couldn't create new DSN!\n"; print DSN $dsncontents; close(DSN); $accessdsn = "FILEDSN=$datadir/Report.dsn";

Where I had previously defined the access file name ($file ), data directory ($datadir ) and then used $accessdsn as the parameter for the call. All I did was create a working file DSN for the database, then copy the contents into my application, changing certain elements to variables. In your case, if the datadir and file name are constant, you could probably just have all the values hardcoded or just put a file DSN in with the Access database.


«Rich36»

In reply to Re: DBD::ODBC connection prob by Rich36
in thread DBD::ODBC connection prob by mifflin

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.