Score:0

Connection string for my SQL Server connection from C on Linux

pf flag

I am trying to connect to SQL Server using C program on Linux.

My connection string is this:

DRIVER = {ODBC Driver 17 for SQL Server}; Server = 192.168.0.25,52000;Database = db; UID = ud, PWD = pw;

When I want to perform a test connection, I get this error:

[unixODBC][Microsoft][ODBC Driver 17 for SQL Server]Login failed for user ''

Something must be wrong with the connection string because it shows empty user '', not 'ud' as in the string above.

So I tried to connect with:

isql -v test

My odbc.ini file is:

[test]
Driver = ODBC Driver 17 for SQL Server
Server = tcp:192.168.0.25,52000
UID = ud
PWD = pw
Database = db

Unfortunately the results were the same:

[unixODBC][Microsoft][ODBC Driver 17 for SQL Server]Login failed for user ''

So I decided to connect with

isql -v test ud "pw"

And now I finally connected. What is wrong with my connection string/odbc.ini file? I read many tutorials and they seem to be ok. But somehow UID and PWD seems to be ommited.

EDIT. Ok, I learned that you cannot pass username and password with odbc.ini but the initial question why it does not work with connection string inside my C program still persists.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.