使用ADO.net的SQL数据库登录faield [英] Sql database login faield using ADO.net

查看:84
本文介绍了使用ADO.net的SQL数据库登录faield的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用sql server 2008创建数据库,然后将其与我的c#接口链接,出现错误meassge,此处'无法打开登录请求的数据库Cofyshop.mdf,登录失败,带

登录用户Beljika \beljk'<<这是错误消息,我的连接字符串是

i make a database using sql server 2008 then linked it with my c# interface , error meassge appear , here it 'Cannot open database Cofyshop.mdf requested by the login,the login failed with
login failed for user Beljika\beljk ' << this is error message and my connection string is

Server=(LOCAL);Database=Cofeshop.mdf;Trusted_Connection=True;





需要帮助



neeed help

推荐答案

你需要提供有效的连接字符串

转到 https://www.connectionstrings.com/sql-server-2008/ [ ^ ]并检查您可以使用的连接字符串格式。



请注意数据库属性是用于数据库的名称,它不等于数据库文件名。



you need to provide valid connection string
go to https://www.connectionstrings.com/sql-server-2008/[^] and check the connection string formats you can use.

note that Database property is for name of the database and it is not equal to database file name.

Quote:

必须使用关键字'database'(或其别名之一)指定数据库名称如下所示:AttachDbFileName = | DataDirectory | \data \YourDB.mdf; integrated security = true; database = YourDatabase。如果日志文件与数据文件位于同一目录中,并且在附加主数据文件时使用'database'关键字,则会生成错误。在这种情况下,请删除日志文件。附加数据库后,将根据物理路径自动生成新的日志文件。

The database name must be specified with the keyword 'database' (or one of its aliases) as in the following: "AttachDbFileName=|DataDirectory|\data\YourDB.mdf;integrated security=true;database=YourDatabase". An error will be generated if a log file exists in the same directory as the data file and the 'database' keyword is used when attaching the primary data file. In this case, remove the log file. Once the database is attached, a new log file will be automatically generated based on the physical path.


您的连接字符串正在使用TrustedConnection。这告诉SQL Server使用运行代码的用户的帐户。它告诉您,您的帐户没有您尝试使用的数据库的权限。
Your connection string is using TrustedConnection. This tells the SQL Server to use the account of the user running the code. It's telling you your account doesn't have permissions to the database you're trying to use.


这篇关于使用ADO.net的SQL数据库登录faield的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆