Hi2All,

Perl newbie debuting here. I have encountered the following persistent problem.

Using:
- Windows XP Professional SP3
- ActivePerl 5.12.1 Build 1201
- PostgreSQL 8.4.4

According to PPM I have the following relevant drivers installed (all up-to-date):
- DBI 1.613
- DBD-ODBC 1.24 (ODBC DBD for Perl DBI)

But when trying to execute the following simple program:

#!usr/bin/perl use warnings; use diagnostics; use strict; use DBI; my $driver = "ODBC"; my $dbname = "test"; my $dsn = "dbi:$driver:$dbname"; my $username = "postgres"; my $password = "************"; my $dbh = DBI->connect($dsn, $username, $password, {PrintError => 0, R +aiseError => 1}) || die "Error $DBI::err [$DBI::errstr]"; print "Connected: State is %s\n", $dbh -> state || "OK"; $dbh->disconnect;

I get the following error message:

Uncaught exception from user code:
DBI connect('test', 'postgres',...) failed: MicrosoftODBC Driver Manager Data source name not found and no default driver specified. (SQL-IM002) at DB_test.plx line 16
at C:/Perl/site/lib/DBI.pm line 675
DBI::__ANON__(undef, undef) called at C:/Perl/site/lib/DBI.pm line 730
DBI::connect('DBI', 'dbi::ODBC::test', 'postgres', '************', 'HASH(0x298dcc)') called at DB_test.plx line 14

After looking for a solution for hours I still can't figure out what's the problem, so in desperation I turn to thy sages of Perl.


In reply to Cannot connect Perl to PostgreSQL using ODBC (SQL-IM002) by lr3p

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.