Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# SQL-Server TcpClient
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
Comments
PIEBALDconsult at 30-Jan-13 13:11pm
   
Why would you not be using the ADO.net classes?
Member 9557085 at 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 at 30-Jan-13 14:30pm
   
Then what is the problem? If it's database-related then ADO.net should work.

1 solution

Rate this: bad
good
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.
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 255
1 Sergey Alexandrovich Kryukov 104
2 Richard MacCutchan 100
3 kbrandwijk 75
4 Vinay Mistry 70
0 Sergey Alexandrovich Kryukov 9,040
1 OriginalGriff 8,121
2 CPallini 2,613
3 Richard MacCutchan 2,221
4 Abhinav S 1,928


Advertise | Privacy | Mobile
Web04 | 2.8.140827.1 | Last Updated 30 Jan 2013
Copyright © CodeProject, 1999-2014
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