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

I'm back with more SQL Server questions. I have installed the DBD ODBC driver. I read something somewhere about a ODBC driver manager..?? I'm trying to connect to SQL Server 2005 server from my Windows XP machine to no avail. I'm really confused on this Data Source Name. Ive created a new System Data Source in the Microsoft Data Source Administrator program called SQLSERVER. Im using this code to try and connect:
my $dbh = DBI->connect('dbi:ODBC:SQLSERVER', 'user', 'pass');
And I get this error:
DBI connect('SQLSERVER','user',...) failed: [Microsoft][ODBC SQL Serve +r Driver][ TCP/IP Sockets]SQL Server does not exist or access denied. (SQL-08001) [Microsoft][ODBC SQL Server Driver][TCP/IP Sockets]ConnectionOpen (Con +nect()). ( SQL-01000)(DBD: db_login/SQLConnect err=-1) at db_config.pl line 16

Replies are listed 'Best First'.
Re: MS SQL Server.....again
by jfroebe (Parson) on Nov 09, 2006 at 21:21 UTC

    The error states that either your ip,port are incorrect in the ODBC settings or that your login/password is incorrect.

    In the ODBC administrator, you can test the connection to verify that the ip/port and login/password are set correctly. ODBC Administrator -> Data Source -> Test Connection.

    HTH,

    Jason L. Froebe

    Team Sybase member

    No one has seen what you have seen, and until that happens, we're all going to think that you're nuts. - Jack O'Neil, Stargate SG-1

      Thank you very much, I tested the connection, and this is the response:
      [Microsoft][ODBC SQL Server Driver][TCP/IP Sockets]SQL Server does not + exist or access denied.

        Understood. You will want to check with your local MS SQL Server DBA. He/she can set you up with the correct info as to ip/port and a login/password. It may be that the sql server is set up integrated (Windows Authentication) authentication. If that is so, then there is more work to be done by the DBA.

        Jason L. Froebe

        Team Sybase member

        No one has seen what you have seen, and until that happens, we're all going to think that you're nuts. - Jack O'Neil, Stargate SG-1

Re: MS SQL Server.....again
by runrig (Abbot) on Nov 09, 2006 at 21:16 UTC
    Does it connect ok from within the DSN administration program?
    Your code does not do any error checking. How are you getting that error?

    Update: PrintError defaults to "on"...that's how you're getting the error...mybad since I usually set RaiseError on and PrintError off.

      IT does seem to connect okay from the DSN admin program. And really good question about the error, I have no clue how it is being generated, but it is.