无法打开登录问题所请求的数据库"XXX" [英] Cannot open database 'XXX' requested by the login problem

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

问题描述



我已经建立了这个小的存储过程,但在运行时会出现错误
无法打开登录请求的数据库销售".登录失败登录失败的用户"MASTER \ MyName".
我知道一个事实,该代码可以在另一个具有不同输入的数据库上工作,但不能在另一个数据库上工作.我使用的是在SQL Server 2005中使用Service Broker引入分布式消息的示例 [ 创建 MASTER KEY ENCRYPTION BY PASSWORD = ' hellopassword'; GO


我不确定这是否有所作为.无论如何,下面是我的C#请帮忙!

SqlConnection conn = null;
          SqlDataReader rdr = null;

          string orderinfo = richTextBox1.Text;

          try
          {
              conn = new SqlConnection(
                  "Server=(local);DataBase=Sales;Integrated Security=SSPI");
              conn.Open();

              SqlCommand cmd = new SqlCommand("runorder", conn);

              cmd.CommandType = CommandType.StoredProcedure;

              cmd.Parameters.Add(new SqlParameter("@order", orderinfo));

              rdr = cmd.ExecuteReader();

          }
          finally
          {
              if (conn != null)
              {
                  conn.Close();
              }
              if (rdr != null)
              {
                  rdr.Close();
              }
          }



PS在用于MASTER \ MyName安全性的用户映射下,该用户设置为dbo并具有数据库所有者的权限.

错误:无法打开登录请求的数据库.登录失败.用户登录失败 [ ^ ]
问题排查:用户"x"的登录失败 [ ^ ]

很少要检查的内容(可能包含您已经做过的事情)
-sql服务器属于同一域(主服务器)
-您的用户在sql服务器登录(或您所属的组之一)中列出了
-上一步的登录名被定义为数据库中的数据库用户
-未禁用登录
-在数据库中未禁用用户

为了使连接完全正常,请尝试使用SQL Server身份验证进行连接(只是测试,而不是永久性的解决方案)


Hi,

I''ve built this little stored procedure peice of code however when I run it it comes up with the error
"Cannot open database "Sales" requested by the login. The login failed Login failed for user ''MASTER\MyName''."
I know for a fact that the code works on another database with diffrent inputs but not this one. Im using the example from this Introducing Distributed Messaging using Service Broker in SQL Server 2005[^] i''ve just changed the variables slightly and have tried to run the stored procedure through my C# app. In the example it sets

CREATE MASTER KEY
ENCRYPTION BY PASSWORD = 'hellopassword';
GO


I''m not sure if that makes a difference. Anyway below is my C# please help!

SqlConnection conn = null;
          SqlDataReader rdr = null;

          string orderinfo = richTextBox1.Text;

          try
          {
              conn = new SqlConnection(
                  "Server=(local);DataBase=Sales;Integrated Security=SSPI");
              conn.Open();

              SqlCommand cmd = new SqlCommand("runorder", conn);

              cmd.CommandType = CommandType.StoredProcedure;

              cmd.Parameters.Add(new SqlParameter("@order", orderinfo));

              rdr = cmd.ExecuteReader();

          }
          finally
          {
              if (conn != null)
              {
                  conn.Close();
              }
              if (rdr != null)
              {
                  rdr.Close();
              }
          }



P.S Under the user mapping for the security of MASTER\MyName the user is set to ''dbo'' and has the permissions of database owner.

解决方案

SQL SERVER – FIX : ERROR : Cannot open database requested by the login. The login failed. Login failed for user ‘NT AUTHORITY\NETWORK SERVICE’[^]

EDIT

Error: Cannot open database requested by the login. The login failed. Login failed for user[^]
Troubleshooting: Login failed for user ''x''[^]


Few things to check (may contain things you''ve already done)
- the sql server is part of the same domain (master)
- your user is listed in sql server logins (or one of the groups you belong to)
- the login from previous step is defined as a database user in the database
- the login isn''t disabled
- the user isn''t disabled in the database

Also to make sore that connection works at all try connecting using SQL Server authentication (just a test, not a permanent solution)


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

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