ADO用了这么久,每次用向导创建ADO的数据库连接字符串时总会有产生一个Persist Security Info属性,平时没太注意,因为设置为True或False时对数据库连接没有任何影响。不过心理还是不爽,今天有时间查询了一下资料,总算搞清楚了它的作用。
Persist Security Info属性的意思是表示是否保存安全信息,其实可以简单的理解为"ADO在数据库连接成功后是否保存密码信息",
SqlDataOperate sqlDataOperate = new SqlDataOperate("Data Source=192.168.0.189;User ID=sa;Password=aa;Initial Catalog=datachange;Persist Security Info=true");
sqlDataOperate.SqlConnection.Open();
SqlDataOperate sqlDataOperate2 = new SqlDataOperate("Data Source=192.168.0.189;User ID=sa;Password=aa;Initial Catalog=datachange;Persist Security Info=false");
sqlDataOperate2.SqlConnection.Open();
string s = sqlDataOperate.SqlConnection.ConnectionString;
string s2 = sqlDataOperate2.SqlConnection.ConnectionString;
结果s2=Data Source=192.168.0.189;User ID=sa;Initial Catalog=datachange;Persist Security Info=false 即没有了password项
Persist Security Info属性的意思是表示是否保存安全信息,其实可以简单的理解为"ADO在数据库连接成功后是否保存密码信息",
SqlDataOperate sqlDataOperate = new SqlDataOperate("Data Source=192.168.0.189;User ID=sa;Password=aa;Initial Catalog=datachange;Persist Security Info=true");
sqlDataOperate.SqlConnection.Open();
SqlDataOperate sqlDataOperate2 = new SqlDataOperate("Data Source=192.168.0.189;User ID=sa;Password=aa;Initial Catalog=datachange;Persist Security Info=false");
sqlDataOperate2.SqlConnection.Open();
string s = sqlDataOperate.SqlConnection.ConnectionString;
string s2 = sqlDataOperate2.SqlConnection.ConnectionString;
结果s2=Data Source=192.168.0.189;User ID=sa;Initial Catalog=datachange;Persist Security Info=false 即没有了password项