Click here to Skip to main content
12,952,159 members (60,492 online)
Rate this:
Please Sign up or sign in to vote.
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 30-Jan-13 6:24am
PIEBALDconsult 30-Jan-13 13:11pm
Why would you not be using the classes?
Member 9557085 30-Jan-13 13:58pm
The connection to the databases are made using the classes where I am providing the connection settings. I tried using the classes to rectify this problem as well but with no success. If you think its possible to achieve this using classes please do let me know. Thanks..
PIEBALDconsult 30-Jan-13 14:30pm
Then what is the problem? If it's database-related then should work.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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.

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

    Print Answers RSS
Top Experts
Last 24hrsThis month
OriginalGriff 6,239
CHill60 3,490
Maciej Los 3,083
Jochen Arndt 1,975
ppolymorphe 1,880

Advertise | Privacy | Mobile
Web02 | 2.8.170525.1 | Last Updated 30 Jan 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100