简体   繁体   English

SQL Server数据库连接字符串

[英]SQL Server Database Connection String

I'm trying to write a program that will fetch data from a SQL Server database. 我正在尝试编写一个程序,该程序将从SQL Server数据库中获取数据。 The program is written on top of the .NET platform using C#. 该程序使用C#在.NET平台上编写。 Furthermore, the program will be running on a Linux host (with mono). 此外,该程序将在Linux主机(带有mono)上运行。 The problem that I am faced with is connecting to the database from the Linux machine, all of my code works fine from a windows host (since the server uses windows authentication), so my question is this: how can I connect to/authenticate with the SQL Server instance? 我面临的问题是从Linux机器连接到数据库,我的所有代码都可以从Windows主机正常运行(因为服务器使用Windows身份验证),所以我的问题是:我该如何连接到/进行身份验证SQL Server实例?

I've looked at http://www.mono-project.com/SQLClient , and it says to use a string similar to this: "Server=MyServer;Database=pubs;User ID=MyWindowsDomain\\\\MyWindowsUserid;Password=MyWindowsPassword;Integrated Security=SSPI" but that is not working. 我查看了http://www.mono-project.com/SQLClient ,它说使用与此类似的字符串: "Server=MyServer;Database=pubs;User ID=MyWindowsDomain\\\\MyWindowsUserid;Password=MyWindowsPassword;Integrated Security=SSPI"但无法正常工作。 Is there maybe something I can do on the server (not likely that I'll be allowed to, but as a last resort)? 也许我可以在服务器上做一些事情(不太可能允许我,但是作为最后的选择)?

Thanks. 谢谢。

您不能将sql server集成身份验证与linux一起使用,而必须使用sql server身份验证

As A. DIMO says, you cannot authenticate using integrated security on *NIX. 正如A. DIMO所说,您无法在* NIX上使用集成安全性进行身份验证。 It's not a windows box. 这不是Windows框。

In your SQL Server Management studio, create a login that uses SQL Server authentication and not Windows Authentication. 在您的SQL Server Management Studio中,创建一个使用SQL Server身份验证而不是Windows身份验证的登录名。 Ensure it has the necessary writes on the database in question. 确保在有关数据库上有必要的写操作。

Next, remove the Integrated Security=SSPI part of the connection string. 接下来,删除连接字符串的Integrated Security=SSPI部分。 That should do the trick. 这应该够了吧。

While not a direct answer to your question, this site is useful for almost any connection string question: http://www.connectionstrings.com/ . 虽然不是您问题的直接答案,但是此网站对于几乎所有连接字符串问题都非常有用: http : //www.connectionstrings.com/

At the risk of sounding like a commercial: It's your one-stop-shop for connection strings! 冒着听起来像商业广告的风险:这是您一站式购买连接弦的机会!

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

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