Connect to SQL server 2005 using SQLDMO

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • João Santa Bárbara

    #1

    Connect to SQL server 2005 using SQLDMO

    Hi all
    i need to know if sql dmo can connect to SQL server 2005
    if can! how can i do this ??

    i have this code

    Dim xServer a SQLDMO.Server
    ......bla..bla. ..

    xServer.LoginSe cure = True
    xServer.Connect ("SQLServer2005 ")

    but it can´t connect.
    is there anyother way ??

    thks
    JSB


  • Ken Tucker [MVP]

    #2
    Re: Connect to SQL server 2005 using SQLDMO

    Hi,

    What are you trying to do with sqldmo?

    Ken
    -----------------
    "João Santa Bárbara" <joaosb@i24port ugal.com> wrote in message
    news:OA1xjFcZFH A.3400@tk2msftn gp13.phx.gbl...
    Hi all
    i need to know if sql dmo can connect to SQL server 2005
    if can! how can i do this ??

    i have this code

    Dim xServer a SQLDMO.Server
    ......bla..bla. ..

    xServer.LoginSe cure = True
    xServer.Connect ("SQLServer2005 ")

    but it can´t connect.
    is there anyother way ??

    thks
    JSB



    Comment

    • João Santa Bárbara

      #3
      Re: Connect to SQL server 2005 using SQLDMO

      i just want the get databases listname

      thks



      "Ken Tucker [MVP]" <vb2ae@bellsout h.net> wrote in message
      news:%23cgSblcZ FHA.3280@TK2MSF TNGP09.phx.gbl. ..[color=blue]
      > Hi,
      >
      > What are you trying to do with sqldmo?
      >
      > Ken
      > -----------------
      > "João Santa Bárbara" <joaosb@i24port ugal.com> wrote in message
      > news:OA1xjFcZFH A.3400@tk2msftn gp13.phx.gbl...
      > Hi all
      > i need to know if sql dmo can connect to SQL server 2005
      > if can! how can i do this ??
      >
      > i have this code
      >
      > Dim xServer a SQLDMO.Server
      > .....bla..bla.. .
      >
      > xServer.LoginSe cure = True
      > xServer.Connect ("SQLServer2005 ")
      >
      > but it can´t connect.
      > is there anyother way ??
      >
      > thks
      > JSB
      >
      >
      >[/color]


      Comment

      • Ken Tucker [MVP]

        #4
        Re: Connect to SQL server 2005 using SQLDMO

        Hi,

        Use the sp_databases stored procedure to list database names.

        Dim strConn As String

        Dim conn As SqlConnection

        Dim cmd As SqlCommand

        Dim dr As SqlDataReader

        strConn = "Server =(local);"

        strConn &= "Database = ; Integrated Security = SSPI;"

        conn = New SqlConnection(s trConn)

        cmd = New SqlCommand("sp_ Databases", conn)

        cmd.CommandType = CommandType.Sto redProcedure

        conn.Open()

        dr = cmd.ExecuteRead er

        If dr.HasRows Then

        Do While dr.Read

        Trace.WriteLine (String.Format( "Name {0} Size {1}", _

        dr.Item("Databa se_Name"), dr.Item("Databa se_Size")))

        Loop

        End If

        dr.Close()

        conn.Close()





        Ken

        ----------------------

        "João Santa Bárbara" <joaosb@i24port ugal.com> wrote in message
        news:OWYlApcZFH A.3164@TK2MSFTN GP09.phx.gbl...
        i just want the get databases listname

        thks



        "Ken Tucker [MVP]" <vb2ae@bellsout h.net> wrote in message
        news:%23cgSblcZ FHA.3280@TK2MSF TNGP09.phx.gbl. ..[color=blue]
        > Hi,
        >
        > What are you trying to do with sqldmo?
        >
        > Ken
        > -----------------
        > "João Santa Bárbara" <joaosb@i24port ugal.com> wrote in message
        > news:OA1xjFcZFH A.3400@tk2msftn gp13.phx.gbl...
        > Hi all
        > i need to know if sql dmo can connect to SQL server 2005
        > if can! how can i do this ??
        >
        > i have this code
        >
        > Dim xServer a SQLDMO.Server
        > .....bla..bla.. .
        >
        > xServer.LoginSe cure = True
        > xServer.Connect ("SQLServer2005 ")
        >
        > but it can´t connect.
        > is there anyother way ??
        >
        > thks
        > JSB
        >
        >
        >[/color]



        Comment

        Working...