Click here to Skip to main content
15,887,985 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am trying to develop an application that runs sql scripts either or on a local or on a remote sql server to update values on the application. The connection status is checked using:

TcpClient client = new TcpClient(serverName, 1433);

Once we know that we can listen using the port, I will have to pass the login credentials to the SQL server either using Windows/SQL server authentication. But the problem is that the application needs to determine if the server it is connecting to is local or remote based on which the functionality of the application can vary.
e.g: Use integrated security if using local windows authentication.

Can anyone please assist me in as to how I would be able to determine if the connection is remote or local as based on this my application can be developed to enable different functionality/properties.

Thank you.
Posted
Comments
PIEBALDconsult 30-Jan-13 13:11pm    
Why would you not be using the ADO.net classes?
Member 9557085 30-Jan-13 13:58pm    
The connection to the databases are made using the ADO.net classes where I am providing the connection settings. I tried using the ADO.net classes to rectify this problem as well but with no success. If you think its possible to achieve this using ADO.net classes please do let me know. Thanks..
PIEBALDconsult 30-Jan-13 14:30pm    
Then what is the problem? If it's database-related then ADO.net should work.

1 solution

You wouldn't normally do this. At install time, you'd ask the person installing the app for the name of the SQL Server and instance, port number, and credentials to use, giving them the option of using Windows Authentication. You'd then construct the connection string from that information and test the connection if required.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900