Error 21776:[SQL-DMO]

  • Hi All,

           I am trying to create a new User using the below sqls.

    1.For creating a user "qtp" in master database.

     USE master

    if not exists (select * from master.dbo.syslogins where loginname = N'qtp')

    BEGIN

     declare @logindb nvarchar(132), @loginlang nvarchar(132)

     select @logindb = N'master', @loginlang = N'us_english'

     if @logindb is null or not exists (select * from master.dbo.sysdatabases where name = @logindb)

      select @logindb = N'master'

     if @loginlang is null or (not exists (select * from master.dbo.syslanguages where name = @loginlang) and @loginlang <> N'us_english')

      select @loginlang = @@language

     exec sp_addlogin N'qtp', 'qtp', @logindb, @loginlang

    END

    GO

    2. Giving the READ only access to NBAPEND database.

    USE NBAPEND

    GO

    if not exists (select * from dbo.sysusers where name = N'qtp' and uid < 16382)

     EXEC sp_grantdbaccess N'qtp', N'qtp'

    GO

    exec sp_addrolemember N'db_datareader', N'qtp'

    GO

    Both the SQLs running without any error.

    After that When using the Enterprise Manger when I select the "database access"  tab for that user and click on the NBAPEND I am getting the below error.

    "Error 21776:[SQL-DMO]The name "qtp" was not found in the Databases collection. If

    the name is a qualified name, use [] to seperate various parts of the name, and

    try again.

    "

    FYI, Once I refresh the user list from the NBAPEND database,after that I won;t get any error.

    and new user will work fine.

    Any help?

     

     

     

     

  • Mitesh

    I think you've stumbled on one of the pitfalls of using Enterprise Damager: that you have to refresh before you do almost anything.

    John

  • yes.....

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply