File tree Expand file tree Collapse file tree 1 file changed +25
-1
lines changed Expand file tree Collapse file tree 1 file changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -519,6 +519,30 @@ void QgsMssqlSourceSelect::on_btnConnect_clicked()
519
519
520
520
QString connectionName = db.connectionName ();
521
521
522
+ // Test for geometry columns table first. Don't use it if not found.
523
+ QSqlQuery q = QSqlQuery ( db );
524
+ q.setForwardOnly ( true );
525
+
526
+ if ( useGeometryColumns )
527
+ {
528
+ QString testquery ( " SELECT count(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'geometry_columns'" );
529
+ q.exec ( testquery );
530
+ int count = q.value ( 0 ).toInt ();
531
+ bool geometryColumnsFound = count != 0 ;
532
+ if ( !geometryColumnsFound )
533
+ {
534
+ QMessageBox::StandardButtons reply;
535
+ reply = QMessageBox::question ( this , " Scan full database?" ,
536
+ " No geometry_columns table found. \n Would you like to search full database (might be slower)? " ,
537
+ QMessageBox::Yes | QMessageBox::No
538
+ );
539
+ if ( reply == QMessageBox::Yes )
540
+ useGeometryColumns = false ;
541
+ else
542
+ return ;
543
+ }
544
+ }
545
+
522
546
// Read supported layers from database
523
547
QApplication::setOverrideCursor ( Qt::WaitCursor );
524
548
@@ -539,7 +563,7 @@ void QgsMssqlSourceSelect::on_btnConnect_clicked()
539
563
}
540
564
541
565
// issue the sql query
542
- QSqlQuery q = QSqlQuery ( db );
566
+ q = QSqlQuery ( db );
543
567
q.setForwardOnly ( true );
544
568
( void )q.exec ( query );
545
569
You can’t perform that action at this time.
0 commit comments