question

LadislavKov-8044 avatar image
0 Votes"
LadislavKov-8044 asked LadislavKov-8044 answered

SQL Server connection string

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-general
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @LadislavKov-8044, did you get any error message for this issue? Here has a thread is elated to connection string for SQL Server. If it doesn't works, please give us more details about this issue.


0 Votes 0 ·
ErlandSommarskog avatar image
0 Votes"
ErlandSommarskog answered

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.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

TomPhillips-1744 avatar image
0 Votes"
TomPhillips-1744 answered
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

LadislavKov-8044 avatar image
0 Votes"
LadislavKov-8044 answered

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".

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.