开发者

WCF fault logging and SQL Exception 4060 error

开发者 https://www.devze.com 2023-01-03 09:16 出处:网络
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

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?


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号