Dropping a user from SQL 2005 Using SMO  
Author Message
Jason Seel





PostPosted: .NET Framework Data Access and Storage, Dropping a user from SQL 2005 Using SMO Top

 

Hi

I have been able to create both logins and users inside databases using SMO in VB.NET the only problem is when i try to drop the user. I get the error

"User does not exist or you do not have permission."

This is un true as I have gold like privliges and can drop the user using the User Interface supplyed with SQL 2005. The user also definetly exists as I have tried both creating it with the User Interface and also using SMO both a username and login are present.

This is the particular code that fails.

'The login has the same name as the user.

Dim usr As User

usr = New User(db, fndsqlusr)

usr.UserType = UserType.SqlLogin

usr.Login = fndsqlusr

usr.Drop()

~~~~~~~~~~~~~~~~~~~~~`

Any Help would be much appriciated

An example would be very helpful also.

Thanks

Jason Seel




.NET Development13