This question has been asked before by others, "answered" and moved, but no real answer. I have Linux driver 11 set up and am trying to connect to a Windows machine with sql server from http://www.microsoft.com/en-us/download/details.aspx?id=28160 on fedora 19x64. If I use sqlcmd on Linux terminal with -S Server..., I connect, but no matter what I seem to do with an adapted C program that was provided by a MS person on a blog http://blogs.msdn.com/b/sqlblog/archive/2012/01/26/use-existing-msdn-c-odbc-samples-for-microsoft-linux-odbc-driver.aspx. It fails at the
// Connect to data source
retcode = SQLConnect(hdbc, (SQLCHAR*) "SQLCMD", SQL_NTS, (SQLCHAR*) "Test1", 5, (SQLCHAR*) "Password1", 9);
with changes to the arguments for me like
// Connect to data source
retcode = SQLConnect(hdbc, (SQLCHAR*) "trogw", 5, (SQLCHAR*) "XX", 2, (SQLCHAR*) "XXXXXXXXXX", 10);
That -H fails to connect on sqlcmd but -S works makes me think something is amiss with the connection string in the c code, or the character width/encoding is not right....
It would be nice to see someone's working connection code.
First, I want to inform that “-H” option is used to specify the current host name where the “SQLCMD” command executes rather the server name where the SQL Server instance runs, we can ignore this option rather the the “-S” option. This can explain the following result:
That -H fails to connect on sqlcmd but -S works
Since we can connect to the SQL Server instance via “SQLCMD”, it indicates the ODBC driver works and this issue is more likely caused by C++ codes. I want to inform that this forum is to discuss SQL Server questions. Regarding the C++ codes issue, I suggest posting the question to C++ forum. Additionally, I want to confirm what’s the error message you received when executing the following command:
// Connect to data source retcode = SQLConnect(hdbc, (SQLCHAR*) "trogw", 5, (SQLCHAR*) "XX", 2, (SQLCHAR*) "XXXXXXXXXX", 10);
For more detail information, you can refer to the following link:
Connecting with sqlcmd
If you have any feedback on our support, please click
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time.
Thanks for helping make community forums a great place.
- Marked as answer by Allen Li - MSFTMicrosoft contingent staff, Moderator Thursday, November 14, 2013 9:49 AM
- Unmarked as answer by Allen Li - MSFTMicrosoft contingent staff, Moderator Friday, November 15, 2013 12:57 AM
Hello mwindham ,
I disagree with you : if it is not working for you , you should have replied to the Allen's post before posting a reply 9 days later, a timespan usually considered as an agreement.
Have a nice day
Mark Post as helpful if it provides any help.Otherwise,leave it as it is.