服务器上的SQL Server Express连接字符串不起作用 [英] SQL Server Express connection string on server not working
问题描述
我已将项目上传到服务器,并且一切正常,直到尝试使用EF登录"或注册"为止.
I have uploaded my project to a server and everything works fine until I try to "log-in" or "register" using EF
有趣的是,在我的PC上,我已经将其与SQL Server Express& SQL Server Compact-它仅在服务器上不起作用
Interestingly, on my PC, I have got this to work with SQL Server Express & SQL Server Compact - it just does not work on the server
在服务器上,我已经安装了SQL Server Express
On the server, I have SQL Server Express installed
这是连接字符串
<add name="DefaultConnection"
connectionString="data source=(localhost);Integrated Security=SSPI;
database=aspnet-MvcDealerConn-20121005200308;
AttachDBFilename=|DataDirectory|aspnet-MvcDealerConn-20121005200308.mdf;
User Instance=true"
providerName="System.Data.SqlClient" />
任何帮助将不胜感激
推荐答案
整个用户实例和AttachDbFileName = 方法都有缺陷-充其量!而且它也已被弃用-不要使用它!
The whole User Instance and AttachDbFileName= approach is flawed - at best! And it's deprecated, too - don't use it!
我要解决的方法是:
-
安装SQL Server Express(并且您已经完成了此操作)
install SQL Server Express (and you've already done that anyway)
安装SQL Server Management Studio Express
install SQL Server Management Studio Express
在 SSMS Express 中创建数据库,并为其指定逻辑名称(例如DealerConn
)
create your database in SSMS Express, give it a logical name (e.g. DealerConn
)
使用其逻辑数据库名称(在服务器上创建时提供)连接至它-请勿随意使用物理数据库文件和用户实例.在这种情况下,您的连接字符串将类似于:
connect to it using its logical database name (given when you create it on the server) - and don't mess around with physical database files and user instances. In that case, your connection string would be something like:
Data Source=servername\\SQLEXPRESS;Database=DealerConn;User ID=SomeUser;Pwd=SecretPwd
其他所有内容与以前完全相同...
and everything else is exactly the same as before...
由于它托管在远程服务器上,因此我也认为您很有可能需要提供单独的显式用户名和密码(并且不能使用Integrated Security=SSPI;
标记)
Since it's hosted on a remote server, I also believe you need to most likely provide a separate, explicit User name and password (and you cannot use the Integrated Security=SSPI;
tag)
这篇关于服务器上的SQL Server Express连接字符串不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!