Skip to content

Commit

Permalink
MSSQL: Show message if geometry_columns not found
Browse files Browse the repository at this point in the history
Funded by TechnologyOne, Australia

- Backported to 2.8.3
- Cherry-picked from 9f0ea0c
  • Loading branch information
NathanW2 committed Jun 19, 2015
1 parent e9181d9 commit 833988f
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/providers/mssql/qgsmssqlsourceselect.cpp
Expand Up @@ -519,6 +519,30 @@ void QgsMssqlSourceSelect::on_btnConnect_clicked()

QString connectionName = db.connectionName();

// Test for geometry columns table first. Don't use it if not found.
QSqlQuery q = QSqlQuery( db );
q.setForwardOnly( true );

if ( useGeometryColumns )
{
QString testquery( "SELECT count(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'geometry_columns'" );
q.exec( testquery );
int count = q.value( 0 ).toInt();
bool geometryColumnsFound = count != 0;
if ( !geometryColumnsFound )
{
QMessageBox::StandardButtons reply;
reply = QMessageBox::question( this, "Scan full database?",
"No geometry_columns table found. \nWould you like to search full database (might be slower)? ",
QMessageBox::Yes | QMessageBox::No
);
if ( reply == QMessageBox::Yes )
useGeometryColumns = false;
else
return;
}
}

// Read supported layers from database
QApplication::setOverrideCursor( Qt::WaitCursor );

Expand All @@ -539,7 +563,7 @@ void QgsMssqlSourceSelect::on_btnConnect_clicked()
}

// issue the sql query
QSqlQuery q = QSqlQuery( db );
q = QSqlQuery( db );
q.setForwardOnly( true );
( void )q.exec( query );

Expand Down

0 comments on commit 833988f

Please sign in to comment.