Seeking help on SQL-DMO

  • Hi all,

    Can any one xplain an easy way to get information on the properties and the methods of DMO objects. I am not able to understand how get. Explain how the DMO objects will work after creating them. I hope I will find an elaborated explanation on it.

    Thanx.

    Madhu.


    Madhu

  • Hi,

    I'm not that much into SQL-DMO, there are many topics in BOL. MSDN is also useful. When it comes to code examples for SQL-DMO it gets thinner. Here's a snippet in VB I created one day...and never finished. It assumes you put a reference to Microsoft SQLDMO Object Library in VB.

    Option Explicit

    Dim i As Integer

    Dim oSQLApplication As SQLDMO.Application

    Dim oSQLServers As SQLDMO.SQLServers

    Dim oSQLServer As SQLDMO.SQLServer

    Dim oSQLDatabases As SQLDMO.Databases

    Dim oSQLDatabase As SQLDMO.Database

    Dim oNameList As SQLDMO.NameList

    Private Sub Form_Load()

    oBorder.FlatBorder (lstServer.hWnd)

    Set oSQLApplication = New SQLDMO.Application

    Set oNameList = oSQLApplication.ListAvailableSQLServers

    For i = 1 To oNameList.Count

    lstServer.AddItem oNameList.Item(i)

    Next i

    End Sub

    Private Sub lstServer_Click()

    On Error Resume Next

    Dim lpszServerName As String

    Err.Clear

    lstDatabase.Clear

    lpszServerName = lstServer.Text

    Set oSQLServer = New SQLDMO.SQLServer

    oSQLServer.LoginSecure = True

    DoEvents

    oSQLServer.Connect lpszServerName

    DoEvents

    '/Connection failed

    If Err <> 0 Then

    lblError.Caption = "Login failed"

    Exit Sub

    Else

    lblError.Caption = ""

    End If

    For i = 0 To oSQLServer.Databases.Count - 1

    Select Case UCase(oSQLServer.Databases(i + 1).Name)

    Case "TEMPDB", "MASTER", "MSDB", "MODEL"

    Case Else

    lstDatabase.AddItem oSQLServer.Databases(i + 1).Name

    End Select

    Next i

    End Sub

    HTH

    Cheers,

    Frank

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • ...and if you've referenced it in VB you can the Object catalog to browse.

    Cheers,

    Frank

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • I've got quite a few articles on DMO here on the site, lots of sample code.

    Andy

    http://www.sqlservercentral.com/columnists/awarren/

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

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