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?


In reply to Moving from SQL Server to ODBC Driver 17 for SQL Server by Takamoto

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.