I’m trying to reuse the connection string from LINQPad 8 in my own code. I’m using the following line to get the connection string:
var connectionString = this.Connection.ConnectionString;
However, when I examine the resulting connection string, I notice that the password is missing. The connection string looks like this:
“Data Source=server.com;User ID=prodUser;Initial Catalog=testdb;app=LINQPad”
When I use LINQPad’s default connection test, it’s successful.
Is there a way to reuse the complete connection string, including the password, instead of having to input it separately in my code?
Would you like me to provide some suggestions on how to handle this issue?
Here is the stack trace :
at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, Boolean applyTransientFaultHandling, String accessToken)
at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)
at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
at System.Data.ProviderBase.DbConnectionPool.WaitForPendingOpen()
— End of stack trace from previous location —
at UserQuery.Main(), line 48
I was expecting the connection string work when I use the Linqpad default connection
Sri Chavali is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.