Skip to content

Commit

Permalink
Retrieve the primary key column when opening MS SQL tables and no ide…
Browse files Browse the repository at this point in the history
…ntity column has been specified
  • Loading branch information
szekerest authored and alexbruy committed Apr 7, 2012
1 parent e25e331 commit 0b1cfe2
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/providers/mssql/qgsmssqlprovider.cpp
Expand Up @@ -404,6 +404,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();
}
}
}
}


Expand Down

0 comments on commit 0b1cfe2

Please sign in to comment.