I'm making a component which uses some data to connect to a database, this data includes user id and password, it store those values in private variables but any programmer can see the value in the debugger after the initialization, so I'm wondering how the SqlConnection does to hide that value, when I see the value of the property ConnectionString I see all the info except the password, its storing it somewhere but its not making it visible, even in the debugger i cant see any variable that's storing the password, I know i can secure the password using SecureString but I'm wondering how is the implementation of SqlConnection object.
Thanks.
Juan Zamudio
The SqlConnection is opened and set as the Connection for the SqlCommand. The example then calls ExecuteNonQuery. To accomplish this, the ExecuteNonQuery is passed a connection string and a query string that is a Transact-SQL INSERT statement. The connection is closed automatically when the code exits the using block.
The sqlConnection will close the connection after it will pass using block and call Dispose method.
The connection string is an expression that contains the parameters required for the applications to connect a database server. In terms of SQL Server, connection strings include the server instance, database name, authentication details, and some other settings to communicate with the database server.
From the manual:
The ConnectionString is similar to an OLE DB connection string, but is not identical. Unlike OLE DB or ADO, the connection string that is returned is the same as the user-set ConnectionString, minus security information if the Persist Security Info value is set to false (default). The .NET Framework Data Provider for SQL Server does not persist or return the password in a connection string unless you set Persist Security Info to true.
I'm not sure about how this is implemented. My unverified guess is that it fills a structure with the security parameters it then sends to the server, never actually storing them unless you set Persist Security Info to true.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With