无法打开数据库"eResourceMgmt";登录要求. [英] Cannot open database "eResourceMgmt" requested by the login.

查看:82
本文介绍了无法打开数据库"eResourceMgmt";登录要求.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要连接到数据库.
当我执行con.open()时,它发出警告
登录名请求无法打开数据库"eResourceMgmt".登录失败.
用户"mycomputer"的登录失败.
我的数据库名称是eResourceMgmt,我用c#
编写

I want to connect to database.
When I execute con.open() it gives warning as
"Cannot open database "eResourceMgmt" requested by the login. The login failed.
Login failed for user ''mycomputer''".
My database name is eResourceMgmt and I have written in c#

SqlConnection con = new SqlConnection("Data Source=.\\SQLEXPRESS;Initial Catalog=eResourceMgmt;Integrated Security=True");



和我的连接属性是
连接字符串-
数据源=.\ SQLEXPRESS; AttachDbFilename ="C:\ Users \ Acer \ Desktop \ DL project \ DL project \ DL PROJECT \ App_Data \ eResourceMgmt.mdf";集成安全性= True;用户实例= True

Owner-mycomputer



and my connection properties are
Connection String--
Data Source=.\SQLEXPRESS;AttachDbFilename="C:\Users\Acer\Desktop\DL project\DL project\DL PROJECT\App_Data\eResourceMgmt.mdf";Integrated Security=True;User Instance=True

Owner-mycomputer

推荐答案

您需要确保提到的登录凭据具有适当的权限.

请按照以下步骤验证连接字符串是否正常工作:无法打开登录请求的数据库"XXXXX".登录失败. [ ^ ]

有关如何配置用户的信息,请参见此处, ^ ]

讨论了类似的问题在此处解决的问题:无法打开数据库登录名要求的测试".登录失败.用户登录失败... [
You need to make sure that the login credentials mentioned have proper permissions.

Follow the following steps to verify if the connection string is working: Cannot open database "XXXXX" requested by the login. The login failed. [^]

See here on how to configure a user, Similar issue just with other user[^]

Similar issue discussed & resolved here: Cannot open database "test" requested by the login. The login failed. Login failed for user...[^]


您可以使用Visual Studio创建连接字符串
http://www.connectionstrings.com/ [^ ]
You can make connection string with visual studio
Using Visual Studio to find a database connection string[^]
and use this connection string.

or try more
http://www.connectionstrings.com/[^]


<pre lang="c#">SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=fullpath of database;Integrated Security=True;User Instance=True");</pre>
from connection properties.


这篇关于无法打开数据库"eResourceMgmt";登录要求.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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