Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB.Net SQLDMO Adding User Problem

Status
Not open for further replies.

AndyLee100

Technical User
Jun 26, 2003
174
GB
Hi,

I have a real problem trying to add a user in VB.Net using SQLDMO. The real crux is that the code works in VB 6.

Would appreciate any help as this problem is doing my head in. Code below-
Code:
    Dim oServerName As New SQLDMO.SQLServer
    Dim oDBLogin As New SQLDMO.Login
    Dim oDBUser As New SQLDMO.User
    Dim odbname As New SQLDMO.Database

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        
        Dim sDatabaseName As String
        oServerName.Connect("pc-andy", "sa", "password")
        sDatabaseName = "Pubs"

        With oDBLogin
            .Database = "pubs"
            .Name = "is"
            .SetPassword("", "Password")
            .Type = SQLDMO.SQLDMO_LOGIN_TYPE.SQLDMOLogin_Standard
        End With

        oServerName.Logins.Add(oDBLogin)

        'odbname = oServerName.Databases(sDatabaseName)

        With oDBUser
            .Name = "XXX"
            .Login = oDBLogin.Name
        End With

        
        odbname = oServerName.Databases(sDatabaseName)
(This is the line it doesnt like!!!)
Error - 'Interface 'SQLDMO.Databases' cannot be indexed because it has no default property.'


        odbname.Users.Add(oDBUser)

    End Sub


Any help would be greatly appreciated.

Thanks

Andy Lee
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top