Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^3: dbi:ODBC change Port

by Corion (Patriarch)
on Nov 10, 2022 at 09:48 UTC ( [id://11148090]=note: print w/replies, xml ) Need Help??


in reply to Re^2: dbi:ODBC change Port
in thread dbi:ODBC change Port

The second parameter to DBI->connect is the username and the third parameter is the password. You are passing in the options hash:

DBI->connect( "dbi:ODBC:Driver={$ODBCdriver};Server=$SQLserver;Database=$SQLdata +base;UID=$SQLuser;PWD=$SQLpassword;Port=$SQLport", { PrintError => 0, RaiseError => 1, AutoCommit => $AutoCommit, FetchHashKeyName => 'NAME_lc' }, );

I would split that up, and construct the values separately to keep things somewhat understandable:

my $dsn = "dbi:ODBC:Driver={$ODBCdriver};Server=$SQLserver;Database=$S +QLdatabase,$SQLport;UID=$SQLuser;PWD=$SQLpassword; ..."; my $dbi_options = { PrintError => 0, RaiseError => 1, AutoCommit => $AutoCommit, FetchHashKeyName => 'NAME_lc' }; my $dbh = DBI->connect( $dsn, undef, undef, $dbi_options );

Replies are listed 'Best First'.
Re^4: dbi:ODBC change Port
by Anonymous Monk on Nov 10, 2022 at 10:12 UTC

    This is a good suggestion and makes the call more readable. I implemented it. However, it does not solve the issue. Calling:

    my $dsn = "dbi:ODBC:Driver={$ODBCdriver};Server=$SQLserver,$SQLport;Da +tabase=$SQLdatabase;UID=$SQLuser;PWD=$SQLpassword; ...";

    Note that I moved ',$SQLport' to Server. This syntax never connects. This is probably because it is not the syntax expected by Perl DBI (all examples on Perlmonks too also use '; Port=1433' which instead always connects no matter the port I use -> this indicates - I guess - that the parameter is not used. To be honest, I have no ideas.

      The Perl DBI does not care about the contents of (the parameters part of) the DSN. This is between you and the ODBC driver, which is why I linked to https://connectionstrings.com.

      As none of the two approaches seem to work, I suggest you look closer at the ODBC driver and the version you have, and then find out what the proper connection string is.

      are the three dots part of your dsn?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11148090]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2024-04-25 19:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found