Search code examples
c#sqlsql-server-2008microsoft-sync-framework

The SELECT permission was denied on the object 'Notes', database 'Sticky', schema 'dbo'


It appears here:

            SyncAdapter notesSyncAdapter = notesBuilder.ToSyncAdapter();
        ((SqlParameter)notesSyncAdapter.SelectIncrementalInsertsCommand.Parameters["@sync_last_received_anchor"]).DbType = System.Data.DbType.Binary;
        ((SqlParameter)notesSyncAdapter.SelectIncrementalInsertsCommand.Parameters["@sync_new_received_anchor"]).DbType = System.Data.DbType.Binary;

The user has has all permissions on both the table, schema and the database. Any idea what might this still throw this exception?

more details: SQLiteConnectionStringBuilder builder = new SQLiteConnectionStringBuilder();

builder["Data source"] = "achernar"; builder["User ID"] = "sbbf974"; builder["Password"] = "whatever"; builder["Integrated Security"] = false; builder["Initial Catalog"] = "sticky";


Solution

  • The issue was with the user, as Abe guessed. The user was dbo, meaning that although it should have had all the permissions, it didn't. So what I've done was to create another login, to which I gave the following database roles: public, db_datareader, db_datawriter. It works now.