SQL Server connection string

Ladislav Kováč 21 Reputation points
2021-03-26T16:01:21.643+00:00

I am unable to connect SQL Server database from my Julia Language code web server; I suspect I am not able to figure out proper connection string.
I have 2 SQL Server ODBC drivers installed on this windows machine, "SQL Server" and "Microsoft ODBC Driver 17 for SQL Server"
I am able to create DSN manually and at the end DSN setup I am able to connect successfully with these credentials.
I have tried many different connection string, most relevant are following (first line is connection string, second error/exception returned:

Server=my.server.net; User ID=loginname; Password=myPassword; driver={SQL Server}; Database=myDB;
ErrorException("HY000: [Microsoft][ODBC SQL Server Driver][SQL Server]Windows logins are not supported in this version of SQL Server.01S00: [Microsoft][ODBC SQL Server Driver]Invalid connection string attribute")

Server=my.server.net; User ID=loginname; Password=myPassword; driver={ODBC Driver 17 for SQL Server}; Database=myDB;
ErrorException("28000: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Login failed for user ''.01S00: [Microsoft][ODBC Driver 17 for SQL Server]Invalid connection string attribute")

Server=my.server.net; UserID=loginname; Password=myPassword; driver={ODBC Driver 17 for SQL Server}; Database=myDB;
ErrorException("28000: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Login failed for user ''.01S00: [Microsoft][ODBC Driver 17 for SQL Server]Invalid connection string attribute")

Server=my.server.net; User Id=loginname; Password=myPassword; driver={ODBC Driver 17 for SQL Server}; Database=myDB;
ErrorException("28000: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Login failed for user ''.01S00: [Microsoft][ODBC Driver 17 for SQL Server]Invalid connection string attribute")

Server=my.server.net; User Id=loginname; Password=myPassword; driver={ODBC Driver 17 for SQL Server}; Trusted_Connection=False; Database=myDB;
ErrorException("08001: [Microsoft][ODBC Driver 17 for SQL Server]Invalid value specified for connection string attribute 'Trusted_Connection'")

Server=my.server.net; User Id=loginname; Password=myPassword; driver={ODBC Driver 17 for SQL Server}; Trusted_Connection=No; Database=myDB;
ErrorException("28000: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Login failed for user ''.01S00: [Microsoft][ODBC Driver 17 for SQL Server]Invalid connection string attribute")

Server=my.server.net; User Id=loginname; Password=myPassword; driver={ODBC Driver 17 for SQL Server}; Trusted_Connection=Yes; Database=myDB;
ErrorException("FA004: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Failed to authenticate the user '' in Active Directory (Authentication option is 'WindowsIntegrated').\r\nError code 0x534; state 10\r\nNo mapping between account names and security IDs was done.01S00: [Microsoft][ODBC Driver 17 for SQL Server]Invalid connection string attribute")

Server=my.server.net; User Id=loginname; Password=myPassword; driver={ODBC Driver 17 for SQL Server}; Trusted_Connection=Yes; Authentication=Server; Database=myDB;
ErrorException("08001: [Microsoft][ODBC Driver 17 for SQL Server]Invalid value specified for connection string attribute 'Authentication'")

Server=my.server.net; User Id=loginname; Password=myPassword; driver={ODBC Driver 17 for SQL Server}; Trusted_Connection=Yes; Authentication=SQLServer; Database=myDB;
ErrorException("08001: [Microsoft][ODBC Driver 17 for SQL Server]Invalid value specified for connection string attribute 'Authentication'")

Any suggestions?

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,650 questions
{count} votes

Accepted answer
  1. Erland Sommarskog 100.8K Reputation points MVP
    2021-03-26T22:33:24.85+00:00

    And to add what Tom says: you want the pattern in the first example. Well, at least if you want to use an SQL Login + password.

    If you want to use integrated security, it is the second example.

    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Tom Phillips 17,716 Reputation points
    2021-03-26T16:48:13.267+00:00
    1 person found this answer helpful.
    0 comments No comments

  2. Ladislav Kováč 21 Reputation points
    2021-03-29T08:05:36.94+00:00

    Thank you! UID/PWD combination works.

    I just got confused with 17/19. I expected (incorrectly) that "ODBC Driver 17 for SQL Server" belongs to "SQL Server 2017".

    0 comments No comments