Retrieve the primary key column when opening MS SQL tables and no identity column has been specified

This commit is contained in:
szekerest 2012-03-27 00:23:06 +02:00 committed by Nathan Woodrow
parent 8f22e21ddd
commit 067d7dd467

View File

@ -337,6 +337,19 @@ void QgsMssqlProvider::loadFields()
}
}
}
// get primary key
if ( mFidColName.isEmpty() )
{
mQuery.clear();
mQuery.exec( QString( "exec sp_pkeys N'%1', NULL, NULL" ).arg( mTableName ) );
if ( mQuery.isActive() )
{
if ( mQuery.next() )
{
mFidColName = mQuery.value( 3 ).toString();
}
}
}
}