Sunday, March 11, 2012

assigning user to a database programmatically

Environment : vc.net , SQL Server
Hi All,
I have programmatically created an SQL Server database
by executing the script file for it. I have logged in as administrator
for creating the above database in my vc.net code using SQL APIs.
Now i need to assign a new user and pasword to this database
i have created in my program. Is there a way to do it ?
Regards,
AsifUse sp_addlogin for adding the login to the database, then use sp_grantdbacc
ess to grant your user access to the database. If you then want to add the
user to a role use sp_addrolemember
hth,
Lance

No comments:

Post a Comment