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
  • Loading branch information
NathanW2 committed Jun 16, 2015
1 parent 8153baf commit 9f0ea0c
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/providers/mssql/qgsmssqlsourceselect.cpp
Original file line number Diff line number Diff line change
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 9f0ea0c

Please sign in to comment.