Loading ...
Sorry, an error occurred while loading the content.

Re: [PBML] Using DBI to connect to a ACCESS db

Expand Messages
  • Jenda Krynicky
    From: nwyork21 ... You either have to create a DSN (Data Source Name) via Start Programs Administrative Tools Data Sources (ODBC) or
    Message 1 of 2 , Oct 22, 2004
    • 0 Attachment
      From: "nwyork21" <nwyork@...>
      > I'm trying to learn how to use DBI, but I can't get pass the connect
      > method.
      >
      > I'm using:
      >
      > my $dbh = DBI->connect('DBI:ODBC:Northwind','admin','password');
      >
      > The part I'm not sure about is the datasource.
      > Everytime I get:
      >
      > DBI connect('Northwind','admin',...) failed: [Microsoft][ODBC Driver
      > Manager] Da ta source name not found and no default driver specified
      > (SQL-IM002) (DBD: db_log in/SQLConnect err=-1) at dbi_test.pl line 3
      >
      > OR:
      >
      > DBI connect('Northwind','admin',...) failed: [Microsoft][ODBC Driver
      > Manager] Da ta source name not found and no default driver specified
      > (SQL-IM002) (DBD: db_log in/SQLConnect err=-1) at dbi_test.pl line 3
      >
      > I've tried many different things, but I'm not sure if I need to
      > specify a ODBC for MS Access or just the db name.

      You either have to create a DSN (Data Source Name) via
      Start\Programs\Administrative Tools\Data Sources (ODBC)
      or specify the ODBC driver and path to the database in the DBI-
      >connect().

      See
      perldoc DBD::ODBC

      from that docs:

      Connect without DSN
      The ability to connect without a full DSN is introduced in version
      0.21.

      Example (using MS Access):
      my $DSN = 'driver=Microsoft Access Driver (*.mdb);
      dbq=\\\\cheese\\g$\\perltest.mdb';
      my $dbh = DBI->connect("dbi:ODBC:$DSN", '','')
      or die "$DBI::errstr\n";

      HTH, Jenda
      ===== Jenda@... === http://Jenda.Krynicky.cz =====
      When it comes to wine, women and song, wizards are allowed
      to get drunk and croon as much as they like.
      -- Terry Pratchett in Sourcery
    Your message has been successfully submitted and would be delivered to recipients shortly.