How to connect remote SQL with Visual Studio 2005?

  • I am using Visual Studio 2005. I have not been able to connect to the remote SQL database at all. I have attempted to write a SMO to make the connection however, the info I have been able to get to on MSDN didn’t have enough information to carry me through.

    Here is the code I’ve been attempting to use.

    Module Module1

    Imports Microsoft.SqlServer.Management.Smo

    Imports Microsoft.SqlServer.Management.Common

     

        Sub Main()

            'Declare a ServerConnection object variable to specify SQL authentication, login and password.

            Dim conn As New ServerConnection

            conn.LoginSecure = False

            conn.Login = XXXXX

            conn.Password = XXXXX

            'Connect to the local, default instance of SQL Server.

            Dim srv As Server

            srv = New Server(conn)

            'The actual connection is made when a property is retrieved.

            Console.WriteLine(srv.Information.Version)

            'The connection is automatically disconnected when the Server variable goes out of scope.

     

        End Sub

     

    End Module

    I really don’t know where this should go or how to cause it to make the connection. If anyone can help with the correct code or where I can find it I will appreciate it. Thanks in advance.

  • In 2005 you have to use the surface area configuration tool to enable SQL Server to allow remote connections, all you need is covered in the link below by Microsoft. And no I don't use either SMO or DMO both are Microsoft property it changes as needed which is not in my best interest.  Hope this helps.

    http://support.microsoft.com/kb/914277

    Kind regards,
    Gift Peddie

  • Thanks for the good help

  • I am glad I could help.

     

    Kind regards,
    Gift Peddie

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

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