Click here to Skip to main content
15,910,009 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi i am making a Database Software in C#.
I have MS SQL2008R2 installed in my PC.
the problem is that my clients computers SQL server name is different then mine.
So, the application does not work. i have used Data Adapters and Data Sets in Coding and i used wizard to configure them.
I am asking that is there any way to like a text file that an application reads to find SQL server name or some thing like that!
Posted

You should use the connection strings element of your config file to specify the connection string

http://msdn.microsoft.com/en-us/library/bf7sd233.aspx[^]

You should then read the value from the config file when setting up your connection. When you need to deploy to other machines, just change the config file value.
 
Share this answer
 
Comments
Waleed_Hassan 10-Dec-11 13:45pm    
Kindly give me some example code!
You can find the information related to that use following codes.


1. To findout "SERVER NAME"
SQL
SELECT SERVERPROPERTY('MACHINENAME') 

2. To findout "SERVER NAME" with "INSTANCE NAME" (If its Named Instance)
SQL
SELECT SERVERPROPERTY('SERVERNAME')


3. To findout "CLIENT MACHINE NAME"(Local Machine Name)
SQL
SELECT HOST_NAME()
 
Share this answer
 
v2
Comments
Waleed_Hassan 29-Nov-11 10:13am    
I am using the Data adopter and data set in the project!
it's may be help you..

use registry..
 
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