2012-12-11 43 views
1

我使用ASP.NET和Entity Framework C#在網上購物Web應用程序的工作。問題是,我的應用程序運行正常,當我測試了我的本地ASP.NET開發服務器上,但是當我主辦的網站,它提供了以下錯誤:應用程序中的服務器錯誤。無效的對象名稱dbo.Categories「

Server Error in '/samarth' Application. Invalid object name 'dbo.Categories'.

Description: An unhandled exception occurred during the execution of the current web 

request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Data.SqlClient.SqlException: Invalid object name 'dbo.Categories'. 

有什麼不對的連接字符串?

<connectionStrings> 
     <add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient"/> 
     <add name="CommerceEntities" connectionString="metadata=res://*/Data_Access.EDM_Commerce.csdl|res://*/Data_Access.EDM_Commerce.ssdl|res://*/Data_Access.EDM_Commerce.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Commerce.mdf;Integrated Security=True;User Instance=True;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient"/> 
    </connectionStrings> 

得到這個錯誤:

The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid.

+0

你問「連接字符串是否有問題? - 但你沒有顯示它! –

+0

查看[this](http://aspspider.info/samarth/)進行演示。 –

+0

這是一個非常明確的錯誤:「無效的對象名'dbo.Categories'。」您的權限錯誤,您指向錯誤的數據庫,並且您沒有正確部署目標數據庫。修理它。 –

回答

2

你得到System.Data.SqlClient.SqlException這意味着你創建連接到數據庫,這個異常是由DATABSE返回,很可能你沒有在服務器上更新的數據庫。檢查您正在連接的數據庫上是否有dbo.Categories exists。你可以閱讀關於連接字符串的更多信息here

+0

我已經上傳了相同的數據庫在服務器上使用。 dbo.Categories存在。 –

+0

檢查連接字符串是否有正確的數據庫服務器和數據庫? – Adil

+0

我的託管服務提供商說我應該把這作爲我的連接字符串:「數據源= \的SQLExpress;堅持安全信息= TRUE;集成安全性= SSPI;初始目錄= YourUserId_DatabaseName」' ' –

相關問題