简体   繁体   中英

SQL Server Database Connection String

I'm trying to write a program that will fetch data from a SQL Server database. The program is written on top of the .NET platform using C#. Furthermore, the program will be running on a Linux host (with 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?

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. 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. It's not a windows box.

In your SQL Server Management studio, create a login that uses SQL Server authentication and not Windows Authentication. Ensure it has the necessary writes on the database in question.

Next, remove the Integrated Security=SSPI part of the connection string. 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/ .

At the risk of sounding like a commercial: It's your one-stop-shop for connection strings!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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