简体   繁体   English

尝试连接到SQL数据库时出现权限错误

[英]Getting a permission error when trying to connect to sql database

I have a sql server on a dedicated machine, running SQL 2008. I have the IP of the box, a database setup on it. 我在运行SQL 2008的专用计算机上有一个sql服务器。我有包装盒的IP,上面有数据库设置。

I've built a small script that just does a connection test, and when I run it, I get the following error. 我构建了一个仅进行连接测试的小脚本,当我运行它时,出现以下错误。

Request for the permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. 请求类型为'System.Data.SqlClient.SqlClientPermission,System.Data,Version = 2.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089'的权限失败。

I've been told by the admin that SQL remote access has been granted for my IP address. 管理员告诉我,已经为我的IP地址授予了SQL远程访问权限。

Anybody know what's wrong? 有人知道怎么了吗?

  • Is your connection string correct? 您的连接字符串正确吗?

Are you using a connection string similar to show here connectionstrings.com 您是否使用类似于此处显示的连接字符串connectionstrings.com

  • Are your username and password correct? 您的用户名和密码正确吗?

username=xxx;pwd=xxx; 用户名= xxx;密码= xxx;

  • Are you using a trusted or non trusted connection? 您使用的是受信任的还是不受信任的连接?

Trusted_Connection=True; Trusted_Connection =真;

  • Can you ping the server in question? 您可以ping有问题的服务器吗?

Might need a bit more info about your environment. 可能需要更多有关您的环境的信息。

Active Directory? 活动目录? Make sure that SQL client is running under a domain account and that it is in the same domain as users trying to access it. 确保SQL客户端在域帐户下运行,并且与尝试访问该客户端的用户位于同一域中。

Let us know if not AD or if that doesn't work, and we'll keep trying from there. 让我们知道不是AD还是不起作用,我们将继续尝试。

(Also, I'm not sure about "remote access has been granted for my IP address." You need actual login credentials.) (此外,我不确定“已为我的IP地址授予远程访问权限。”您需要实际的登录凭据。)

Has the SQL Server been configured to allow remote connections yet using the appropriate protocol - I'd presume TCP/IP. 是否已将SQL Server配置为允许远程连接但仍使用适当的协议-我假设使用TCP / IP。 If it's a fresh install this step may have been missed. 如果是全新安装,则可能已错过此步骤。

After confirming the basic config the steps CResults has listed should get you there. 确认基本配置后,CResults列出的步骤应该可以帮助您。

To force TCP/IP (if your client defaults to somthing else), try adding this to your connectionstring ";Network Library=dbmssocn", so that it looks something like this: 要强制使用TCP / IP(如果您的客户端默认不使用其他方式),请尝试将其添加到连接字符串“; Network Library = dbmssocn”中,使其看起来像这样:

Data Source=ipAddressHere;Initial Catalog=dbName;User Id=user;Password=pass;Network Library=dbmssocn

or 要么

Data Source=tcp:ipAddressHere,1433;Initial Catalog=dbName;User Id=user;Password=pass

To help rule out any sys-admin type problems I would recommend connecting using SQL Management studio on your client machine. 为了排除任何系统管理员类型的问题,我建议您在客户端计算机上使用SQL Management Studio进行连接。 If this isn't available use the Visual Studio Server Explorer to initiate a connection. 如果不可用,请使用Visual Studio服务器资源管理器启动连接。

Assuming this connects then verify you can run whichever SQL command you are using in your test. 假设此连接成功,然后验证您可以运行测试中使用的任何SQL命令。

原来是一个.NET安全问题。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM