Run-time error '-2147217911 (80040e09)':
SELECT permission denied on object <table_name>, database <db_name>, owner <owner_name>
SELECT permission denied on object <table_name>, database <db_name>, owner <owner_name>
Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.
View products that this article applies to.
Dim cn As ADODB.Connection
Dim cn2 As ADODB.Connection
Dim rs As ADODB.Recordset
Dim strConn As String, strSQL As String
' Open Connect with Admin rights
Set cn2 = New ADODB.Connection
cn2.ConnectionString = "Provider=SQLOLEDB;database=pubs;User ID=<username>;Password=<strong password>;server=football"
cn2.Open
'Create a new login
cn2.Execute "sp_addlogin testuser2"
'Create a new view
cn2.Execute "CREATE VIEW view_auth2 AS select * from authors"
'Revoke all rights on the table the view is based on for the guest user account
cn2.Execute "revoke all on authors from guest"
'Grant all rights on the view for the guest account
cn2.Execute "GRANT SELECT , INSERT , DELETE , UPDATE ON dbo.view_auth2 TO guest"
'login with view the new login
strConn = "Provider=SQLOLEDB;database=pubs;User ID=testuser2;Password=;server=football"
Set cn = New ADODB.Connection
cn.Open strConn
'Open a recordset based on the view
strSQL = "select * from view_auth2"
Set rs = New ADODB.Recordset
rs.CursorLocation = adUseClient
rs.Open strSQL, cn, adOpenStatic, adLockOptimistic, adCmdText
'Change a value in the recordset and attempt to update the view
rs!au_lname = rs!au_lname & "z"
rs.Update 'Errors here because the action query is created against the base table
'or to see potential problems with Resync, comment the previous 2 lines and uncomment the following
'rs.Resync adAffectCurrent 'errors here
Keywords: kbdatabase, kbprb, kbserver, KB253673