Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Dynamic OleDbConnection problem: windows app.config

This seemed to work before but now acting up? Have a VB.NET 2003, windows form, OleDbConnection, due to security need to decrypt connection string pulled from app.config before passing to Access database file. I do this via a call to a function in a module:

Dim EncryptConnectionString As String

EncryptConnectionString = CType(configurationAppSettings.GetValue("OleDbConnection1.ConnectionString", GetType(System.String)), String)

Me.OleDbConnection1.ConnectionString = decrypt(EncryptConnectionString)

Though this used to work seems now to be in a Catch 22 situation. I can enter the code above in the #Region " Windows Form Designer generated code ", but it unsets the dynamic connection property in the IDE. If I set the dynamic connection property in the IDE to map to a key in the app.config file, i.e., OleDbConnection1.ConnectionString, it rewrites the #Region " Windows Form Designer generated code " and erases over the decryption code above.

Any thoughts? Can I do call the decryption outside the Windows Form Designer generated code ?? Any other solutions? VERY IMPORTANT!! ANY RESOLUTIONS, THOUGHTS, GUESSES APPRECIATED Any other way to decrypt a connection string?
[1223 byte] By [DaveC] at [2007-11-11 9:55:58]
# 1 Re: Dynamic OleDbConnection problem: windows app.config
I would definitely change the ConnectionString outside of the Windows Form Designer generated code. You should be able to do this during application startup.
pclement at 2007-11-11 21:45:14 >