Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have to Connect to database Which is in a remote machine. Database is in SQL Server 2008 is in remote Machine Where Admin login and password and SQL login is known.
Posted
Comments
Malli_S 26-Sep-12 9:45am    
Where are you stuck? What's the exact problem?

1 solution

Hi Ramesh, its easy to use SqlConnection Class. You just need to build a connection string and create an instance of SqlConnection.

C#
string ConnectionString = "Data Source=[your remote server IP]\[username];Initial Catalog=[databasename to connect];Persist Security Info=True;User ID=[sqluserid];Password=[sqluserPassword]"

SqlConnection sqlConn = new SqlConnection(ConnectionString);
sqlConn.Open();
 
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