Click here to Skip to main content
15,884,986 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have deployed and connected my web application to remote server. To maintain the db I have developed application in windows forms. It works well in local host. Now, I want this windows application to connect to remote server, How to do it? Hereunder I submit the code that I used for windows application to connect to local host. I also have user id and password for remote server.


C#
public partial class NewProductAddition : Form
    {
        SqlConnection con = new SqlConnection();
        string Constring = "Server=localhost;database=prasiddhi;Integrated security=sspi";
Posted
Comments
[no name] 4-May-14 6:58am    
www.connectionstrings.com
Sampath Lokuge 4-May-14 7:13am    
Are you asking how to connect to the SQL server or what ?
S.Rajendran from Coimbatore 4-May-14 10:45am    
What you said is correct . Thank you.

You just have to change your connection string. But you should put it in your app.config first so you don't have to recompile every time you need to change it.

See http://msdn.microsoft.com/en-us/library/ms184658(v=vs.100).aspx[^]

You connection string just has to point to the new server. See http://www.connectionstrings.com/[^] for examples.
 
Share this answer
 
1) Connect your server with Sql server management studio.

2) If database is not created at your server, then first create database there. you can do it with two ways. by creating backup of database from your local machine and restore it to the server.

3)in web.config just replace your connection string with live ip of server or domain name. you have to also provide username and password in web.config.
 
Share this answer
 
SqlConnection con = new SqlConnection();
string Constring = "Server=Serveranme/sql2008;database=prasiddhi;Integrated security=sspi";


in Server=Serveranme/sql2008 or use ip 192.165.1.1/sql2008


first you connect using sql server ,if getting connection then change your connection string like above method
 
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