This feature will be removed in a future version of Microsoft SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature.
The AddMember method assigns Microsoft SQL Server database or server role membership to the specified user, database role, or login.
Configuring role membership by using the AddMember method of the Database and ServerRole objects requires appropriate permissions.
For the Database object, the database user mapped to the SQL Server login used for SQLServer object connection must be a member of the fixed database role db_owner.
For the ServerRole object, the SQL Server login used for SQLServer object connection must be a member of the role to which the specified login will be added.