Can someone please show me how to store the connection string to my Access mdb in my project's My.Settings ?
Thanks
Printable View
Can someone please show me how to store the connection string to my Access mdb in my project's My.Settings ?
Thanks
Open the Settings tab of the project properties and add a Setting of type ConnectionString. Follow the Protected Configuration link in my signature to see how to edit it at run time and encrypt it for security.
Note that if you add a Data Source to your project for the database then it will save the connection string to the config file by default.
That is great info. Thanks very much.Quote:
Originally Posted by jmcilhinney
Do I need to import anything from your Protected Configuration project or do I follow the code in your FormEncrypt's Tools menu ?Quote:
Originally Posted by jmcilhinney
Code:
'Open the primary config file.
Dim config As System.Configuration.Configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None)
'Encrypt the connections strings section.
With config.ConnectionStrings.SectionInformation
.ProtectSection(Nothing)
.ForceSave = True
End With
'Save the changes.
config.Save(ConfigurationSaveMode.Full)
Have you read the documentation for all the types and members I'm using in that code? That's how you will gain understanding. If you're just copying and pasting someone else's code without understanding it then you're not learning.