Skip to content

Commit

Permalink
Do not abort if sp_pkeys is not working
Browse files Browse the repository at this point in the history
  • Loading branch information
szekerest authored and NathanW2 committed Mar 28, 2012
1 parent 45def21 commit f07b3f9
Showing 1 changed file with 18 additions and 20 deletions.
38 changes: 18 additions & 20 deletions src/providers/mssql/qgsmssqlprovider.cpp
Expand Up @@ -364,30 +364,28 @@ void QgsMssqlProvider::loadFields()
if ( mQuery.next() ) if ( mQuery.next() )
{ {
mFidColName = mQuery.value( 3 ).toString(); mFidColName = mQuery.value( 3 ).toString();
return;
} }
else }
foreach( QString pk, pkCandidates )
{
mQuery.clear();
if (!mQuery.exec( QString( "select count(distinct [%1]), count([%1]) from [%2].[%3]" )
.arg( pk )
.arg( mSchemaName )
.arg( mTableName ) ))
{ {
foreach( QString pk, pkCandidates ) QString msg = mQuery.lastError().text();
QgsDebugMsg( msg );
}
if ( mQuery.isActive() )
{
if ( mQuery.next() )
{ {
mQuery.clear(); if (mQuery.value( 0 ).toInt() == mQuery.value( 1 ).toInt())
if (!mQuery.exec( QString( "select count(distinct [%1]), count([%1]) from [%2].[%3]" )
.arg( pk )
.arg( mSchemaName )
.arg( mTableName ) ))
{
QString msg = mQuery.lastError().text();
QgsDebugMsg( msg );
}
if ( mQuery.isActive() )
{ {
if ( mQuery.next() ) mFidColName = pk;
{ return;
if (mQuery.value( 0 ).toInt() == mQuery.value( 1 ).toInt())
{
mFidColName = pk;
break;
}
}
} }
} }
} }
Expand Down

0 comments on commit f07b3f9

Please sign in to comment.