locked
How to connect to the remote SQL Server instance? RRS feed

  • Question

  • I'm sure that 1434 UDP and 1433 TCP are opened. The client is able to see the remote sql server instance but it can not connect to the instance.

    The client construct the connection string like below:

    public static SqlConnection GetDBConnection(string source, string initCat)
            {
                var connectionStringBuilder = new SqlConnectionStringBuilder();
                connectionStringBuilder.IntegratedSecurity = true;
                connectionStringBuilder.DataSource = source;
                connectionStringBuilder.InitialCatalog = initCat;            
    
                var sqlConnection = new SqlConnection();
                sqlConnection.ConnectionString = connectionStringBuilder.ConnectionString;
                return sqlConnection;
            }
    


    and the invokation and trying to connect:

    var con = GetDBConnection("TESTSERVER\\TESTSRV", "TicketSales");
                try
                {
                    con.Open();
                }
                catch (Exception ex)
                {
    
                }
    

    The server says that it does not know the username or there is an invalid password. Is it possible to connect remotely using IntegratedSecurity?

    Tuesday, December 13, 2011 11:16 AM

Answers

  • Can you show exact error message? http://www.connectionstrings.com/sql-server-2008

    If remote comp is on the same domain and your login is granted to connect to SQL Server than YES


    Best Regards, Uri Dimant SQL Server MVP http://dimantdatabasesolutions.blogspot.com/ http://sqlblog.com/blogs/uri_dimant/
    • Marked as answer by EngineerSpock Wednesday, December 14, 2011 4:59 AM
    Tuesday, December 13, 2011 12:49 PM
  • The server says that it does not know the username or there is an invalid password. Is it possible to connect remotely using IntegratedSecurity?  


    Is the client logged into the same domain as the SQL Server?  Are both client and server on the same network or are you connecting over the internet?  As Uri requested, the actual exception message might provide more clues (not sure how that's captured with an empty catch block, though).

     


    Dan Guzman, SQL Server MVP, http://weblogs.sqlteam.com/dang/
    • Marked as answer by EngineerSpock Wednesday, December 14, 2011 4:59 AM
    Tuesday, December 13, 2011 1:24 PM
  • If as Dan mentioned are you going over the internet for the connection instead of of using the servername and the instance name you will probably have to use the "IP Address\TestSRV,1433"

    If you are not on the same domain as Uri asked you will need to be able to pass the correct domain account through as you have the connection using integrated security.

    I hope this helps.


    Warwick Rudd
    MCT MCITP SQL Server 2008 Admin
    My Blog
    -------------------------------------------------------
    Please mark as Answered if I have answered your question
    Please vote if this was useful
    -------------------------------------------------------
    • Marked as answer by EngineerSpock Wednesday, December 14, 2011 5:00 AM
    Tuesday, December 13, 2011 7:40 PM

All replies

  • Can you show exact error message? http://www.connectionstrings.com/sql-server-2008

    If remote comp is on the same domain and your login is granted to connect to SQL Server than YES


    Best Regards, Uri Dimant SQL Server MVP http://dimantdatabasesolutions.blogspot.com/ http://sqlblog.com/blogs/uri_dimant/
    • Marked as answer by EngineerSpock Wednesday, December 14, 2011 4:59 AM
    Tuesday, December 13, 2011 12:49 PM
  • The server says that it does not know the username or there is an invalid password. Is it possible to connect remotely using IntegratedSecurity?  


    Is the client logged into the same domain as the SQL Server?  Are both client and server on the same network or are you connecting over the internet?  As Uri requested, the actual exception message might provide more clues (not sure how that's captured with an empty catch block, though).

     


    Dan Guzman, SQL Server MVP, http://weblogs.sqlteam.com/dang/
    • Marked as answer by EngineerSpock Wednesday, December 14, 2011 4:59 AM
    Tuesday, December 13, 2011 1:24 PM
  • If as Dan mentioned are you going over the internet for the connection instead of of using the servername and the instance name you will probably have to use the "IP Address\TestSRV,1433"

    If you are not on the same domain as Uri asked you will need to be able to pass the correct domain account through as you have the connection using integrated security.

    I hope this helps.


    Warwick Rudd
    MCT MCITP SQL Server 2008 Admin
    My Blog
    -------------------------------------------------------
    Please mark as Answered if I have answered your question
    Please vote if this was useful
    -------------------------------------------------------
    • Marked as answer by EngineerSpock Wednesday, December 14, 2011 5:00 AM
    Tuesday, December 13, 2011 7:40 PM
  • No there is no domain. Now I understand the problem))) I will google the problem of Active Directory and domain creation. Thank you.
    Wednesday, December 14, 2011 4:59 AM