Skip to content
Permalink
Browse files

MSSQL: Show message if geometry_columns not found

Funded by TechnologyOne, Australia

- Backported to 2.8.3
- Cherry-picked from 9f0ea0c
  • Loading branch information
NathanW2 committed Jun 16, 2015
1 parent e9181d9 commit 833988f9b40fd908d2a9e48f45279816d5337e40
Showing with 25 additions and 1 deletion.
  1. +25 −1 src/providers/mssql/qgsmssqlsourceselect.cpp
@@ -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 );

@@ -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 );

0 comments on commit 833988f

Please sign in to comment.
You can’t perform that action at this time.