保留安全信息 属性=true 和保留安全信息 属性=false

Persist Security Info Property=true and Persist Security Info Property=false

对于属性:

Persist Security Info=true

Persist Security Info=false

你能告诉我它们之间有什么区别吗,如果我不把它放在我的连接中会发生什么?

connect.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;
                            Data Source=C:/Users/Nourah/Downloads 
                            /Phase3/Salary.accdb; 
                            Persist Security Info=False;";

即使您设置 Persist Security Info=truePersist Security Info=false 它不会预先显示出差异。差异发生在后台。

Persist Security Info=False时,安全敏感 信息(例如密码)不会作为 connection 如果连接是打开的或曾经处于打开状态 状态。

如果您设置 Persist Security Info=True,Windows 将记住连接字​​符串中指定的密码。

这就是区别。

MSDN Explanation

设置Persist Security Info true 或 false 仅当您在连接字符串中提及用户名和密码时才会生效。如果您在连接字符串中提及用户名和密码并将 Persist Security Info 设置为 false,则无法提取凭据,但是如果您在连接字符串中提供凭据时将 Persist Security Info 设置为 true,windows 将记住凭据,并且可以通过编程方式将其提取。

我从 Dan Guzman here 那里找到了这个答案,SQL 服务器 MVP:

I suggest you specify FALSE or omit the keyword entirely since it is the default, even during development. The only time you need to specify TRUE is if the application uses SQL authentication and subsequently retrieves the password from the connection object, which in my experience is rarely done or needed. Performance is not a concern.