Reputation: 89
class Program
{
private const string Sqlconnstr = "Data Source=.;Initial Catalog = LINQtoSQL;UID = Scarface;PWD = kaka1983513!;";
static void Main(string[] args)
{
var dataContext = new DataContext(Sqlconnstr);
var books = dataContext.GetTable<Book>();
var query = from book in books
select book;
var list = query.ToList(); //If i uncomment this line,i can't get the full string without 'PWD = 123456'.
Console.WriteLine(dataContext.Connection.ConnectionString);
Console.ReadLine();
}
}
How can I get the full string with 'PWD = 123456'
after query.ToList()
command.
Upvotes: 2
Views: 1946
Reputation: 239664
I'm not sure why you would need to read the connection information back out, but I think what you're falling foul of is PersistSecurityInfo:
When set to false or no (strongly recommended), security-sensitive information, such as the password, is not returned as part of the connection if the connection is open or has ever been in an open state. Resetting the connection string resets all connection string values including the password. Recognized values are true, false, yes, and no.
The default value for this connection string parameter is false
.
Upvotes: 5