c# - 使 .NET SqlConnection 不使用 Windows session 凭据

标签 c# .net sqlconnection

出于某种原因,我的 .NET (C#) SqlConnection 使用我的 Windows session 凭据而不是指定的凭据。有没有办法忽略我的 session 凭据并使用我指定的凭据?

SqlConnection myConnection = new SqlConnection("user id=user;" +
                                   "password=pass;server=10.0.10.99;" +
                                   "Trusted_Connection=yes;" +
                                   "database=databasename; " +
                                   "connection timeout=5");
myConnection.Open();

最佳答案

删除 Trusted_Connection=yes;,它表示使用了集成安全性并导致您的 Windows 凭据被使用。

有关连接字符串属性的快速引用,您可以查看:

The Connection String Reference

关于c# - 使 .NET SqlConnection 不使用 Windows session 凭据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8313568/

相关文章:

c# - ascx 文件中的 Response.AddHeader

c# - 杀死应用程序打开的所有线程

c# - 开关盒忽略 Console.ReadLine()

c# - SqlConnections、Parallel.For、一个旧的 C# 应用程序和随机挂起初始化 SqlConnections

vb.net - 在不关闭 SQL 读取器的情况下关闭 SqlConnection - 它会导致连接泄漏吗

c# - 具有通用测试的 Nunit 基类

c# - SQL Server CE 中的正确日期时间格式?

.net - Git在windows中更改 '.git'文件夹名称

c# - 还记得 .net 中的 SQL 连接状态吗?

c# - 在 C# 中使用空 using 语句关闭一次性对象是一种好习惯吗?