0
votes

I have a WCF service built in C# and it uses a connection string to conncect to a Database.

connectionString="Data Source=AXSLV501\SQLA;Passwordxxx;User ID=xxx;Initial Catalog=E1DSPXDCDB"

This works perfectly when the WCF service is hosted as such within Visual Studio 2010, the connection works fine.

However, when I host the WCF service inside a Windows Service however I get a problem. The service is hosted OK, however the database becomes unaccessable.

I can alter the conncetion string changing the instance name (\SQLA) for the port number (1433) like bellow and it works fine. "Data Source=AXSLV501,1433;Passwordxxx;User ID=xxx;Initial Catalog=E1DSPXDCDB"

I am curious as to why the instance name does not work when the service is hosted through a windows service, but does when hosted through visual studio.

Further to my curiosity I have a system which generates the connection strings automatically so without changing it I need the WCF service to work with instance names.

I am using Windows Server 2008 R2 and .net 3.5

1

1 Answers

0
votes

Maybe this in only have a user permissions issue. That Windows Service, ¿which Windows User is using?

  • Start - Run - services.msc
  • Find your service - Right click - Properties - User Login

More: Do you have any restriction in your Windows' Firewall? Maybe VStudio has all the traffic allowed, but that windows service, hasn't.