Skip to content

Commit

Permalink
Improve the support for OGR/MSSQL driver
Browse files Browse the repository at this point in the history
  • Loading branch information
szekerest authored and alexbruy committed Feb 11, 2012
1 parent b3807b7 commit 40623c5
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
25 changes: 25 additions & 0 deletions src/app/ogr/qgsogrhelperfunctions.cpp
Expand Up @@ -85,6 +85,31 @@ QString createDatabaseURI( QString connectionType, QString host, QString databas
uri += QString( ",password=%1" ).arg( password );
}
}
else if ( connectionType == "MSSQL" )
{
uri = "MSSQL:";

if ( !host.isEmpty() )
{
uri += QString( ";server=%1" ).arg( host );

if ( !port.isEmpty() )
uri += QString( ",%1" ).arg( port );
}

if ( !user.isEmpty() )
{
uri += QString( ";uid=%1" ).arg( user );

if ( !password.isEmpty() )
uri += QString( ";pwd=%1" ).arg( password );
}
else
uri += ";trusted_connection=yes";

if ( !database.isEmpty() )
uri += QString( ";database=%1" ).arg( database );
}
else if ( connectionType == "Oracle Spatial" )
{
uri = "OCI:" + user;
Expand Down
5 changes: 4 additions & 1 deletion src/app/ogr/qgsopenvectorlayerdialog.cpp
Expand Up @@ -313,7 +313,10 @@ void QgsOpenVectorLayerDialog::accept()
bool makeConnection = false;
if ( pass.isEmpty() )
{
pass = QInputDialog::getText( this,
if ( cmbDatabaseTypes->currentText() == "MSSQL" )
makeConnection = true;
else
pass = QInputDialog::getText( this,
tr( "Password for " ) + user,
tr( "Please enter your password:" ),
QLineEdit::Password, QString::null,
Expand Down
4 changes: 4 additions & 0 deletions src/providers/ogr/qgsogrprovider.cpp
Expand Up @@ -1448,6 +1448,10 @@ QString createFilters( QString type )
{
myDatabaseDrivers += QObject::tr( "MySQL" ) + ",MySQL;";
}
else if ( driverName.startsWith( "MSSQL" ) )
{
myDatabaseDrivers += QObject::tr( "MSSQL" ) + ",MSSQL;";
}
else if ( driverName.startsWith( "OCI" ) )
{
myDatabaseDrivers += QObject::tr( "Oracle Spatial" ) + ",OCI;";
Expand Down

0 comments on commit 40623c5

Please sign in to comment.