Skip to content

Commit c322cd5

Browse files
committedSep 3, 2012
Specify port 1433 for FreeTDS by default. Allow to specify server/database/uid/password when the driver setting is present (fixes #6259, fixes #6263)
1 parent 500c64a commit c322cd5

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed
 

‎src/providers/mssql/qgsmssqlprovider.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -214,19 +214,20 @@ QSqlDatabase QgsMssqlProvider::GetDatabase( QString driver, QString host, QStrin
214214
#ifdef WIN32
215215
connectionString = "driver={SQL Server}";
216216
#else
217-
connectionString = "driver={FreeTDS}";
217+
connectionString = "driver={FreeTDS};port=1433";
218218
#endif
219-
if ( !host.isEmpty() )
220-
connectionString += ";server=" + host;
219+
}
221220

222-
if ( !database.isEmpty() )
223-
connectionString += ";database=" + database;
221+
if ( !host.isEmpty() )
222+
connectionString += ";server=" + host;
224223

225-
if ( password.isEmpty() )
226-
connectionString += ";trusted_connection=yes";
227-
else
228-
connectionString += ";uid=" + username + ";pwd=" + password;
229-
}
224+
if ( !database.isEmpty() )
225+
connectionString += ";database=" + database;
226+
227+
if ( password.isEmpty() )
228+
connectionString += ";trusted_connection=yes";
229+
else
230+
connectionString += ";uid=" + username + ";pwd=" + password;
230231

231232
if ( !username.isEmpty() )
232233
db.setUserName( username );

0 commit comments

Comments
 (0)
Please sign in to comment.