Hi

I'm running on a Win2K w/SP1 system.

I've searched hi/lo for a clear example on how to connect and use ODBC to
get to an MS/SQL Server database.

I'm trying to connect to a SQL Server system on my local network (resides on
\\SQLSRVR).

I've defined an ODBC data source name using the Control Panel ->
Administrative Tools -> Data Sources (ODBC) -> System DSN

I specified under the Name column: TestDB
the Driver is: SQL Server

In the configuration of the entry the Name shows up correctly as TestDB and
the Server to connect to shows up as SQLSRVR.

When setting up the entry, the testing of the connection indicated that it
was successful (able to interact with the DB).

When I list the available ODBC drivers (using example in Programming the
Perl DBI book), it shows:

Driver: ODBC
        Data Source is DBI:ODBC:Visual FoxPro Database
        . . .
        Data Source is DBI:ODBC:TestDB
        . . .

So I know that the ODBC connection is there.

In my test program I:
        my $conn = DBI->connect( "dbi:ODBC:DSN=TestDB", 'sa', ''') or die...
        my $sth = $conn->prepare( " CREATE TABLE ..."} or die...
        $sth->execute or die...

The connect fails with the following error message:
    DBI->connect(DSN=TestDB) failed: [Microsoft][ODBC Driver Manager] Data
source name not found and no default driver specified (SQL-IM002)(DBD:
db_login/SQLConnect err=-1)

I am suspecting that I am not specifying the DSN properly.

I would love to see a simple example with actual values in the connect
statement corresponding to an ODBC connection to an MS/SQL Server database.

-TIA
David




Reply via email to