2012-12-11 30 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”' ' –

相关问题