Click here to Skip to main content
15,879,019 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi
I want to connect to database in another program
I use this code

C#
connection.ConnectionString = @"Server=localhost;Integrated Security=SSPI";


but what I have to put instead of "localhost" to connect to database that are located in another program ?

thanks in advance :)
Posted

Trythis one

add name="Constr" connectionString="Data Source=path of server name(its may be your LAN Remote server );Initial Catalog=Database name; Persist Security Info=True;User ID=useid;Password=password;" providerName="System.Data.SqlClient
 
Share this answer
 
Comments
maxpower12345 18-Apr-12 16:05pm    
thanks a lot :) enggmichael
 
Share this answer
 
Comments
Vipin_Arora 18-Apr-12 8:43am    
+5 for nice link
Mohammad A Rahman 18-Apr-12 8:52am    
Thanks Vipin :)
Tony Tom.k 18-Apr-12 8:58am    
good one
Mohammad A Rahman 18-Apr-12 9:01am    
Thanks Tony :)
maxpower12345 18-Apr-12 16:04pm    
thanks a lot :) Mohammad
For any ConnetionString, visit:

http://www.connectionstrings.com/[^]

click on Database Servers that you are using and get the connection string...
 
Share this answer
 
Comments
maxpower12345 18-Apr-12 16:05pm    
thanks a lot wipin :)
Try below Solution.


con = New SqlConnection("Data Source=192.168.101.102;Initial Catalog=test_data;Persist Security Info=True;User ID=wml;Password=win")
 
Share this answer
 
Comments
maxpower12345 18-Apr-12 16:06pm    
thanks a lot Dipak :)
Dipak V Nakum 21-Apr-12 6:52am    
Okey
Hello

Try this
C#
con = New SqlConnection("Data Source=MachineNameOnWhichDataBaseIsPlaced;Initial Catalog=DataBasename;Persist Security Info=True;User ID=SQLServerId;Password=Password")
 
Share this answer
 
v2

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