Skip to content
Permalink
Browse files

Allow to specify driver in the MSSQL connection string (#5703)

  • Loading branch information...
szekerest committed Nov 13, 2018
1 parent f8a6d69 commit d7fa02e14a379a256e2d066261a2f12fdcf44843
Showing with 11 additions and 6 deletions.
  1. +11 −6 mapmssql2008.c
@@ -556,7 +556,8 @@ static void setConnError(msODBCconn *conn)
/* Connect to db */
static msODBCconn * mssql2008Connect(const char * connString)
{
SQLCHAR fullConnString[1024];
SQLCHAR outConnString[1024];
SQLSMALLINT outConnStringLen;
SQLRETURN rc;
msODBCconn * conn = msSmallMalloc(sizeof(msODBCconn));

@@ -568,13 +569,17 @@ static msODBCconn * mssql2008Connect(const char * connString)

SQLAllocHandle(SQL_HANDLE_DBC, conn->henv, &conn->hdbc);

snprintf((char*)fullConnString, sizeof(fullConnString), "DRIVER=SQL Server;%s", connString);

if (strcasestr(connString, "DRIVER=") == 0)
{
SQLCHAR outConnString[1024];
SQLSMALLINT outConnStringLen;
SQLCHAR fullConnString[1024];

snprintf((char*)fullConnString, sizeof(fullConnString), "DRIVER={SQL Server};%s", connString);

rc = SQLDriverConnect(conn->hdbc, NULL, fullConnString, SQL_NTS, outConnString, 1024, &outConnStringLen, SQL_DRIVER_NOPROMPT);
rc = SQLDriverConnect(conn->hdbc, NULL, fullConnString, SQL_NTS, outConnString, 1024, &outConnStringLen, SQL_DRIVER_NOPROMPT);
}
else
{
rc = SQLDriverConnect(conn->hdbc, NULL, connString, SQL_NTS, outConnString, 1024, &outConnStringLen, SQL_DRIVER_NOPROMPT);
}

if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {

0 comments on commit d7fa02e

Please sign in to comment.
You can’t perform that action at this time.