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

Hi monks

I am having big issues changing ODBC drives and moving from a SQL Server to a ODBC Driver 17 for SQL Server (or 19).

I am on Windows (10), using DBI, drivers 'SQL Server', 'ODBC Driver 17 for SQL Server', 'ODBC Driver 19 for SQL Server', are installed on the machine, server is SQLEXPRESS, authentication is 'Windows Authentication'.

The following works fine:

#!/usr/bin/perl -w use strict; use DBI; use DBD::ODBC; #my $ODBCdriver = 'SQL Server'; my $ODBCdriver = 'ODBC Driver 17 for SQL Server'; my $SQLport = '4433'; my $SQLserver = 'FC4FA9\SQLEXPRESS'; my $SQLdatabase = ''; my $SQLuser = ''; my $SQLpassword = ''; connect_IB($ODBCdriver, $SQLport, $SQLserver, $SQLdatabase, $SQLuser, +$SQLpassword); sub connect_IB { my ($ODBCdriver, $SQLport, $SQLserver, $SQLdatabase, $SQLuser, $SQ +Lpassword) = @_; print "Connecting SERVER...\n"; my $dbh = DBI->connect("dbi:ODBC:Driver={$ODBCdriver};Server=$SQLs +erver;UID=$SQLuser;PWD=$SQLpassword", {PrintError => 0, RaiseError => + 1, AutoCommit => 1, FetchHashKeyName => 'NAME_lc'}); print "Out Connection String: ", $dbh->{odbc_out_connect_string}, +"\n"; print "Connected...\n"; print "Disconnecting...\n"; $dbh->disconnect if ($dbh); print "Disconnected...\n"; }

However if I change the driver $ODBCdriver to 'ODBC Driver 17 for SQL Server' I get:

DBI connect('Driver={ODBC Driver 17 for SQL Server};Server=FC4FA9\SQLE +XPRESS;UID=;PWD=;Port=4433','HASH(0x6ba7d0)',...) failed: [Microsoft] +[ODBC Driver 17 for SQL Server][SQL Server]Login failed for user ''. +(SQL-28000) [state was 28000 now 01S00] [Microsoft][ODBC Driver 17 for SQL Server]Invalid connection string at +tribute (SQL-01S00) at .\ODBC.pl line 20.

I tried some permutations, but unsuccessfully. Documentations seem scarce. Any idea?

Replies are listed 'Best First'.
Re: Moving from SQL Server to ODBC Driver 17 for SQL Server
by Takamoto (Monk) on Feb 17, 2023 at 10:59 UTC

    Adding the following solved the connection issue:

    Trusted_Connection=yes;