Click here to Skip to main content
15,892,674 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hey friends i am creating simple windows form application and i used local database to configure database in app but now client have sql server database connection and they give me userid and password later so how can my app get that connection \ constring .

help me plz.
Posted

You just need to change your connection string to point to their database. See http://www.connectionstrings.com/[^] for examples.
 
Share this answer
 
What Exactly you want to do?

If the line of code for connection is all you need. Go for:-

string str = @"data source=DEEPAKSHARMA-PC\SQLEXPRESS;initial catalog=new; integrated security=true";
SqlConnection con = new SqlConnection(str);
con.Open();
"YOUR CODE"
con.close();

Where the words in bold should be your SQL SERVER NAME. You can do following steps:-

1. Open Sqlserver Management Studio
2. Go to File-->Connection Object Explorer
3. Copy SERVER NAME
4. Replace DEEPAKSHARMA-PC\SQLEXPRESS with your copied code.

Or if you have user id and password,

Write this code:-

XML
string str = @"data source=<b>DEEPAKSHARMA-PC\SQLEXPRESS</b>;initial catalog=new; user id="Your ID""; password="Your PASSWORD"";
        SqlConnection con = new SqlConnection(str);
        con.Open();
"YOUR CODE"
        con.close();
 
Share this answer
 
Comments
Member 11543226 15-Apr-15 1:01am    
i have that code sir i used local database in my project becouse i dont have sql connection thats not have id nd passwaord bt the client give me their id nd passward bt till i created setup file of project so how can i change connection string to there connection string which contains their id nd passward
Deepak Kanswal Sharma 15-Apr-15 2:25am    
So you want the code on your local server. Right?
I guess you have to get sql server installed on your PC for that.

If I'm wrong , please correct me.

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