views:

17

answers:

2

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?

A: 

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

It's fairly clear you have a login error to your database. Where is the exception throwing? In your client app or in your WCF Service call?

The reason I ask is to point you at where to debug; if the exception is coming from a fault contract on the WCF call, it's most likely occurring in the service itself. If it's on the client app then obviously this is where the issue is.

What version of SQL are you using? If you have SQL Express then by default you should have sufficient permissions to run the app. Is your user an administrator? You may need to open the database as an admin and then ensure that Bill-PC\Bill has a login and has been mapped onto the dbo schema in the WCFLogbook database.

Spence
Spence - Thank you for your help. As you will see below, unfortunately the database was not being created as I thought (a path issue), and after correcting the path in the sql file, the app worked as hoped. Once again, thanks for the help. Bill
Bill
+1  A: 

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.
Remus Rusanu
Remus - As it turned out, after stepping through the WCFLogbook.sql file used to create the WCFLogbook database, I realized that the file was attempting to create the database with a non-existent path - i.e 'C:\Program Files\Microsoft SQL Server\MSSQL\data\WCFLogbook.mdf'. Thus the database wasn't truly being created. Thank you for your help. Bill
Bill