Search code examples
sql-servervb6database-administration

The SELECT permission on table of user's own schema was denied


I have two applications on VB 6.0, AppOK and AppFailed. Both are connecting with a database on SQL Server with user AppUser and querying a table. AppOK succeeds and AppFailed fails with following error message.

Run-time error '-2147217911 (80040e09)':

The SELECT permission was denied on the object 'xxxxx', database 'xxxxx', schema 'xxxxx'.

The table exists in AppUser's schema and when i grant the SELECT permission to the user explicitly it says

Cannot grant, deny, or revoke permissions to sa, dbo, entity owner, information_schema, sys, or yourself.

The AppFailed is able to query all other tables within the schema but fails on newly created 4 tables while AppOK can query all of them.

The Connection String of both the applications are exactly the same. Querying those 4 new tables via Management Studio while connected with AppUser works fine. The AppUser does not have any DENY permission.

I am unable to figure out the problem.


Solution

  • :(. The application was changing the Role of the user itself right after making connection (I didn't know about this), the role did not have rights for the newly created tables.