The HasDBAccess property reports whether a user has explicit permissions to access a database.
object.HasDBAccess
Object
Expression that evaluates to an object in the Applies To list
Boolean
Read-only
HRESULT GetHasDBAccess (LPBOOL pRetVal);
After a connection is established to Microsoft® SQL Server™, an application can use the HasDBAccess property to determine whether a user has explicit access to a particular database. If HasDBAccess returns FALSE, the user does not have access. Use the Grant, Deny, or Revoke methods to manipulate user database permissions.