Skip to content

Commit 876b8c7

Browse files
committed
Improve the support for OGR/MSSQL driver
1 parent 8496494 commit 876b8c7

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

src/app/ogr/qgsogrhelperfunctions.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,31 @@ QString createDatabaseURI( QString connectionType, QString host, QString databas
8484
uri += QString( ",password=%1" ).arg( password );
8585
}
8686
}
87+
else if ( connectionType == "MSSQL" )
88+
{
89+
uri = "MSSQL:";
90+
91+
if ( !host.isEmpty() )
92+
{
93+
uri += QString( ";server=%1" ).arg( host );
94+
95+
if ( !port.isEmpty() )
96+
uri += QString( ",%1" ).arg( port );
97+
}
98+
99+
if ( !user.isEmpty() )
100+
{
101+
uri += QString( ";uid=%1" ).arg( user );
102+
103+
if ( !password.isEmpty() )
104+
uri += QString( ";pwd=%1" ).arg( password );
105+
}
106+
else
107+
uri += ";trusted_connection=yes";
108+
109+
if ( !database.isEmpty() )
110+
uri += QString( ";database=%1" ).arg( database );
111+
}
87112
else if ( connectionType == "Oracle Spatial" )
88113
{
89114
uri = "OCI:" + user;

src/app/ogr/qgsopenvectorlayerdialog.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,10 @@ void QgsOpenVectorLayerDialog::accept()
312312
bool makeConnection = false;
313313
if ( pass.isEmpty() )
314314
{
315-
pass = QInputDialog::getText( this,
315+
if ( cmbDatabaseTypes->currentText() == "MSSQL" )
316+
makeConnection = true;
317+
else
318+
pass = QInputDialog::getText( this,
316319
tr( "Password for " ) + user,
317320
tr( "Please enter your password:" ),
318321
QLineEdit::Password, QString::null,

src/providers/ogr/qgsogrprovider.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1637,6 +1637,10 @@ QString createFilters( QString type )
16371637
{
16381638
myDatabaseDrivers += QObject::tr( "MySQL" ) + ",MySQL;";
16391639
}
1640+
else if ( driverName.startsWith( "MSSQL" ) )
1641+
{
1642+
myDatabaseDrivers += QObject::tr( "MSSQL" ) + ",MSSQL;";
1643+
}
16401644
else if ( driverName.startsWith( "OCI" ) )
16411645
{
16421646
myDatabaseDrivers += QObject::tr( "Oracle Spatial" ) + ",OCI;";

0 commit comments

Comments
 (0)