Skip to content

Commit 0c5930f

Browse files
committed
Merge pull request #91 from szekerest/master
Improve the support for OGR/MSSQL driver
2 parents c933dce + 1be0e87 commit 0c5930f

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

src/app/ogr/qgsogrhelperfunctions.cpp

+25
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

+4-1
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,10 @@ void QgsOpenVectorLayerDialog::accept()
316316
bool makeConnection = false;
317317
if ( pass.isEmpty() )
318318
{
319-
pass = QInputDialog::getText( this,
319+
if ( cmbDatabaseTypes->currentText() == "MSSQL" )
320+
makeConnection = true;
321+
else
322+
pass = QInputDialog::getText( this,
320323
tr( "Password for " ) + user,
321324
tr( "Please enter your password:" ),
322325
QLineEdit::Password, QString::null,

src/providers/ogr/qgsogrprovider.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -1668,6 +1668,10 @@ QString createFilters( QString type )
16681668
{
16691669
myDatabaseDrivers += QObject::tr( "MySQL" ) + ",MySQL;";
16701670
}
1671+
else if ( driverName.startsWith( "MSSQL" ) )
1672+
{
1673+
myDatabaseDrivers += QObject::tr( "MSSQL" ) + ",MSSQL;";
1674+
}
16711675
else if ( driverName.startsWith( "OCI" ) )
16721676
{
16731677
myDatabaseDrivers += QObject::tr( "Oracle Spatial" ) + ",OCI;";

0 commit comments

Comments
 (0)