简体   繁体   English

错误:基础提供程序在打开时失败。 用户的system.data.sqlclient.sqlexception登录失败

[英]Error: the underlying provider failed on open. system.data.sqlclient.sqlexception login failed for user

After deploying my C# win app in client computer, the following error occurs: 在客户端计算机上部署我的C#win应用程序后,发生以下错误:

The underlying provider failed on open.system.data.sqlclient.sqlexception 基础提供程序在open.system.data.sqlclient.sqlexception上失败

login failed for user. 用户登录失败。 cannot open database "EmdadKhordo" Requested by the login 无法打开登录名请求的数据库“ EmdadKhordo”

This is my connection string: 这是我的连接字符串:

metadata=res://*/Models.EmdadKhodroDB.csdl|res://*/Models.EmdadKhodroDB.ssdl|res://*/Models.EmdadKhodroDB.msl;provider=System.Data.SqlClient;provider connection string="data source=.;initial catalog=EmdadKhodroDB;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"

I use Entity Framework to access a SQL Server database. 我使用实体框架访问SQL Server数据库。

Based on the cannot access database error message, authentication succeeded to the SQL instance but the specified database cannot be accessed. 根据无法访问数据库错误消息,SQL实例身份验证成功,但是指定的数据库无法访问。 This may be because the EmdadKhodroDB database does not exist, is not online, or (most likely) inaccessible under the current security context. 这可能是因为EmdadKhodroDB数据库不存在,不在线或在当前安全上下文下(很可​​能)不可访问。 Make sure the account you are using has access to the database and the needed object permissions. 确保您使用的帐户具有数据库访问权限和所需的对象权限。

The DCL below will add the user to the database. 下面的DCL将用户添加到数据库中。 You will also need to grant object level permissions directly to the user or a role of which the user belongs. 您还需要直接向用户或用户所属角色授予对象级别权限。

USE EmdadKhodroDB;
CREATE USER [YourDomain\YourAccount];

You can also manage your Windows user rights using SQL Management Studio . 您也可以使用SQL Management Studio管理Windows用户权限。 Just follow instructions from here for creating a new login and also configure mappings to each database you need access to. 只需按照此处的说明创建新的登录名,并配置到您需要访问的每个数据库的映射即可。

Basically you need to make sure that your login is properly defined (Security -> Logins) and that it has the appropriate rights on EmdadKhordo database (read, write etc.). 基本上,您需要确保正确定义了您的登录名(“安全性”->“登录名”),并且对EmdadKhordo数据库具有适当的权限(读,写等)。 The recommendation is to allow the minimum required rights (eg do not allow to alter tables, if only SELECT, INSERT, UPDATE, DELETE statements are performed by the user). 建议允许最低的必需权限(例如,如果用户仅执行SELECT,INSERT,UPDATE,DELETE语句,则不允许更改表)。

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

相关问题 System.Data.SqlClient.SqlException:用户“ user”的登录失败 - System.Data.SqlClient.SqlException: Login failed for user 'user' System.Data.SqlClient.SqlException:用户“”登录失败 - System.Data.SqlClient.SqlException: Login failed for user '' 如何修复 System.Data.SqlClient.SqlException:用户登录失败 - How to fix System.Data.SqlClient.SqlException: Login failed for user 用户的Azure登录失败? System.Data.SqlClient.SqlException - Azure Login failed for user? System.Data.SqlClient.SqlException System.Data.SqlClient.SqlException:用户“ sa”的登录失败 - System.Data.SqlClient.SqlException: Login failed for user 'sa' System.Data.SqlClient.SqlException:用户“ ...”的登录失败 - System.Data.SqlClient.SqlException: login failed for user '…' System.Data.SqlClient.SqlException:用户登录失败 - System.Data.SqlClient.SqlException: Login failed for user System.Data.SqlClient.SqlException:“用户 'sa' 登录失败。” - System.Data.SqlClient.SqlException: 'Login failed for user 'sa'.' System.Data.SqlClient.SqlException:无法打开登录请求的数据库“数据库”。 登录失败 - System.Data.SqlClient.SqlException: Cannot open database “Database” requested by the login. The login failed System.Data.SqlClient.SqlException:无法打开登录请求的数据库。 登录失败 - System.Data.SqlClient.SqlException: Cannot open database requested by the login. The login failed
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM