Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi

I have this on my WinXP pc;
use DBI; $dsn = 'dbi::Sybase:MY_Sybase_DB'; $user = 'db_analyst'; $password = 'db_pass'; $dbh = DBI->connect($dsn,$user, $passwd);
And I get this back when I run it;
Can't connect to data source My_Sybase_db, no database driver specified and DBI_DSN env var not se t at U:\scripts\dbi_test1.pl line 5
Any reason why this is happening? And how can I connect to my Sybase db successfully?

nb: I have created a valid DSN for my Sybase DB using the ODBC admin software from the Control Panel.

Regards to all Monks.

Replies are listed 'Best First'.
Re: Connecting to Sybase DB using DBI module
by VSarkiss (Monsignor) on Jun 09, 2004 at 15:21 UTC

    A couple of points:

    • I don't know if it's just a copy-and-paste issue, but you have too many colons in your $dsn. It should be
      $dsn = 'dbi:Sybase:My_sybase_server';
    • More importantly, do you have the Sybase client installed on your machine? Even if the server is located on the box, you'll need the Sybase Open Client to connect.

    A good way to check would be to try using some other facility (some freeware client, for example) to connect to the database. If that fails or succeeds, it should give you a strong clue what to do.

Re: Connecting to Sybase DB using DBI module
by derby (Abbot) on Jun 09, 2004 at 15:18 UTC
    That should be dbi:Sybase not dbi::Sybase.

    -derby
Re: Connecting to Sybase DB using DBI module
by mpeppler (Vicar) on Jun 09, 2004 at 19:49 UTC
    nb: I have created a valid DSN for my Sybase DB using the ODBC admin software from the Control Panel.
    Just an FYI - DBD::Sybase does NOT use ODBC at all, so the DSN you created will not be used.

    Michael

      I see,..... I did not know this.(Sybase will not use the DSN i have created)

      OK, I will install Sybase open client and try again,....I will get back to you with my findings.

      btw: does this mean that Only MS dabases such as MS access uses DSN names? or am I missing something else here?...I will soon find out :-(

      Thanks for your help so far.
        No - you can use ODBC to connect to a Sybase database, provided that you have a Sybase ODBC driver installed. In that case you can use DBD::ODBC to access a Sybase server.

        DBD::Sybase uses Sybase's native C API, and so will not use any ODBC settings you may have defined.

        Michael