Search code examples
sqlwcfaccessibilityservicemodelex

WCF fault logging and SQL Exception 4060 error


I have been attempting to compile/run a sample WCF application from Juval Lowy's website (author of Programming WCF Services & founder of IDesign) for several days. The example app utilizes Juval's ServiceModelEx library which logs faults/errors to a "WCFLogbook" SQL database. Unfortunately, when the sample app faults, I get the following error:

SQL Exception 4060: "Cannot open database \"WCFLogbook\" requested by the login. The login failed.\r\nLogin failed for user 'Bill-PC\Bill'."

I confirmed that the SQL WCFLogbook database has been created and have granted all of the appropriate permissions for my (Bill-PC\Bill) access to the database. Additionally port 8006 and port 1433 have been opened in the Firewall. TCP/IP has been enabled and "Allow remote connections to this server" has been checked. I am using the following endpoint within the App.Config file:

<client>
     <endpoint name="LogbookTCP"
        address="net.tcp://Bill-PC:8006/LogbookManager"
        binding="netTcpBinding"
        contract="ILogbookManager"
     />
</client>

Unfortunately SQL is a 'world' that I hadn't needed to venture into before now and I am terribly frustrated with my lack of success. Would anyone have any other suggestions on how to get this working? Have I missed anything?


Solution

  • Cannot open database "WCFLogbook" requested by the login

    The error message is pretty clear. I understand your frustration, but I trust the error message first and your investigation second. The error message says the database does not exists, or it cannot be opened, or user has no access to it. You must validate step by step that:

    • your WCF service connects to the SQL Server instance you expect
    • the that database WCFLogbook exists on the SQL Server instance you are connecting to. Note that if you installed a case sensitive collation instance, then the name is case sensitive
    • the database WCFLogbook is online
    • the login Bill-PC\Bill is allowed to connect to the database.