简体   繁体   English

实体框架无法打开登录请求的数据库 - 用户登录失败

[英]Entity Framework Cannot Open Database Requested By the Login - The Login Failed For User

I've just uploaded my website to a server and getting an error called "cannot open database requested by the login the login failed login failed for user". 我刚刚将我的网站上传到服务器并收到一条名为“无法打开登录请求的数据库登录失败登录失败的用户”的错误。

In my global.asax file on Application_Start method, I have this : 在Application_Start方法的global.asax文件中,我有:

Database.SetInitializer<MyContext>(null);

So I created my database manually and after used script to create tables. 所以我手动创建了我的数据库,并在使用脚本创建表之后。 But when I want to login, it gives me an error. 但是当我想登录时,它会给我一个错误。

On my database my tables, username and password for login page seem fine. 在我的数据库中,我的表,登录页面的用户名和密码似乎很好。 Just can't connect to the database. 只是无法连接到数据库。

My connectionstring is: 我的连接字符串是:

 <add name="MyDatabase" connectionString="Data Source=serveradress;Initial Catalog=MyDatabase;User ID=username;Password=password;MultipleActiveResultSets=True;App=EntityFramework" providerName="System.Data.SqlClient" />

I'll be grateful for advice. 我会很感激你的建议。

Connection to database server 连接数据库服务器

You should check if your server can connect to the database server. 您应该检查您的服务器是否可以连接到数据库服务器。 Perhaps a firewall is blocking the connection. 也许防火墙阻止了连接。

If the server is using TCP/IP, then the simple way is to just telnet to the SQL Server port and see if it connects. 如果服务器使用TCP / IP,那么简单的方法是只是telnet到SQL Server端口并查看它是否连接。 By default, that's port 1433, so this should work: 默认情况下,这是端口1433,所以这应该工作:

telnet servername 1433

That will probably be appropriate in most cases. 在大多数情况下,这可能是合适的。

If it's using a different port, or dynamic ports (common with a named instance), then you'll need to determine which port it's currently listening on. 如果它使用不同的端口或动态端口(与命名实例共用),那么您需要确定它当前正在侦听的端口。 Check SQL Server configuration manager to see if it's a specific port, or dynamic ports. 检查SQL Server配置管理器以查看它是特定端口还是动态端口。 If it's using dynamic ports, then as long as you don't have multiple instances on the server, netstat -abn is probably the simplest way to find what it's using. 如果它使用动态端口,那么只要您在服务器上没有多个实例, netstat -abn可能是找到它正在使用的最简单的方法。 Otherwise, dig through the Windows event log or the SQL Server error log for a message indicating which port is in use by the instance. 否则,请浏览Windows事件日志或SQL Server错误日志,以获取指示实例正在使用哪个端口的消息。

If SQL Server is using Named Pipes, then I believe if you're able to access shares on the machine, you have adequate network connectivity. 如果SQL Server使用命名管道,那么我相信如果您能够访问计算机上的共享,则您具有足够的网络连接。 This article says you can go further and try connecting to the IPC$ share: 本文说你可以进一步尝试连接到IPC $共享:

http://msdn.microsoft.com/en-us/library/aa275787%28v=sql.80%29.aspx http://msdn.microsoft.com/en-us/library/aa275787%28v=sql.80%29.aspx

net use \\servername\IPC$

Security settings on database server 数据库服务器上的安全设置

Go to SQL Server >> Security >> Logins and right click on "username" and select Properties. 转到SQL Server >>安全>>登录,右键单击“用户名”,然后选择“属性”。

登录

In newly opened screen of Login Properties, go to the “User Mapping” tab. 在新打开的“登录属性”屏幕中,转到“用户映射”选项卡。 Then, on the “User Mapping” tab, select the desired database – especially the database for which this error message is displayed. 然后,在“用户映射”选项卡上,选择所需的数据库 - 尤其是显示此错误消息的数据库。 On the lower screen, check the required role. 在屏幕下方,检查所需的角色。

用户映射

I've just solved the problem. 我刚刚解决了这个问题。 The problem is "typical programmers problem". 问题是“典型的程序员问题”。 I needed to write MyDatabase but I wrote MyDatabse. 我需要写MyDatabase但是我写了MyDatabse。 I'm trying to solve this problem since at 11 o'clock. 我想在11点以后解决这个问题。 Thank you for your all replies. 谢谢你的回复。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 实体框架 SqlException:无法打开登录请求的数据库“”。 用户 &#39;domain\\userid&#39; 登录失败 - Entity Framework SqlException: Cannot open database “” requested by the login . The login failed for user ' domain\userid’ 无法打开用户 C# 登录失败请求的数据库 - Cannot open database requested by the login the login failed for user C# 无法打开登录请求的数据库“ [数据库]”。 登录失败。 用户“ [User]”的登录失败 - Cannot open database “[Database]” requested by the login. The login failed. Login failed for user '[User]" 无法打开登录请求的数据库“MyBase”。 登录失败。 用户“域\用户”登录失败 - Cannot open database "MyBase" requested by the login. The login failed. Login failed for user 'domain\User' 无法打开登录请求的数据库“身份”。 登录失败。 用户“DESKTOP\User”登录失败 - Cannot open database “Identity” requested by the login. The login failed. Login failed for user 'DESKTOP\User' 无法打开登录请求的数据库“Test”。 登录失败。 用户&#39;sa&#39;登录失败 - Cannot open database “Test” requested by the login. The login failed. Login failed for user 'sa' 无法打开登录请求的数据库“”。 登录失败。 用户“ sa”的登录失败 - Cannot open database “” requested by the login. The login failed. Login failed for user 'sa' 无法打开登录请求的数据库“databaseName”。登录失败。用户登录失败 - Cannot open database “databaseName" requested by the login. The login failed. Login failed for user 无法打开登录请求的数据库“ dbTest”。 登录失败。 用户“ testUser”的登录失败 - Cannot open database 'dbTest' requested by the login. The login failed. Login failed for user 'testUser' 无法打开登录请求的数据库“测试”。 登录失败。 用户 &#39;xyz\ASPNET&#39; 登录失败 - Cannot open database "test" requested by the login. The login failed. Login failed for user 'xyz\ASPNET'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM