Reputation: 423
I'd like to know how to link my WCF application with a remote SQL Server database. By remote, I mean that is on the same network than me but not on the same computer/project. I've the controll of the computer where the database is stored on.
What I've done so far : create my WCF application and try to add an ADO.NET connection. My issue : where to find the name of the server ? (and also : is it the good way to proceed ?).
Thanks !
Upvotes: 0
Views: 495
Reputation: 1062865
where to find the name of the server?
Three options:
SqlDataSourceEnumerator
(not a fan of this option, to be honest)Upvotes: 2
Reputation: 3256
I suggest you add connectionString
in the Web.config
file of the application
<add name="connectionString"
connectionString="Data Source=ServerName/PC-Name;Initial Catalog=DatabaseName;User ID=userid;Password=pass"
providerName="System.Data.SqlClient" />
Use the connection string
in your code/Logic
string conn = ConfigurationManager.ConnectionStrings["connectionString"].ConnectionString;
Upvotes: 1
Reputation: 133403
Conntion string should look like
Server=myServerName\myInstanceName;Database=myDataBase;User Id=myUsername;Password=myPassword;
In Place of myServerName you can use IPAdress of machine
Upvotes: 1