I am trying to connect to a MS-SQL server on the internet. What should I put on the ServerName parameter of SQLConnect?
I've tried this, but it fails:
"DRIVER=SQL Server;SERVER=SERVER_IP;DATABASE=sales"
SERVER_IP is something like 111.111.111.111,9999
EDIT: I followed Johns advice and here is my current code:
SQLCHAR OutConnStr[255];
SQLSMALLINT OutConnStrLen;
SQLTCHAR *srv = (SQLTCHAR *)"Provider=SQLOLEDB.1;Password=pw;Persist Security Info=True;User ID=me;Initial Catalog=mydb;Data Source=1.2.3.4,9999";
rc = SQLDriverConnect(conn_h, NULL, srv, strlen((char*)srv), OutConnStr, 255, &OutConnStrLen, SQL_DRIVER_PROMPT);
But now I get this error HY024 - Invalid attribute value
See Question&Answers more detail:os