Click here to Skip to main content
12,634,651 members (23,775 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C#3.5
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 26-Sep-12 3:33am
Comments
Malli_S 26-Sep-12 9:45am
   
Where are you stuck? What's the exact problem?

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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

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();
  Permalink  

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.161208.2 | Last Updated 26 Sep 2012
Copyright © CodeProject, 1999-2016
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