You can add any connection string, this example will show for Microsoft Access - yes people still use this database.
- Open the web.config file.
- If you do not see a section called
, then add one. The section should be inside the section.
You may see, if this is the case erase this line and start typing:
. If you have code sense turned on, very quickly you should be able to hit the key and you will end up with
If so, put the cursor between the ">" and the "<" symbols and hit enter. You will end up with
start typing here - Okay, in the "start typing here, area, insert:
I like to add this line to ensure my connection is not duplicated as I add it - Now, just below this line, enter this line:
- Note the "conMyConnection" from the remove name and the add name should match
- Now, in your VB code, you can define a string such as:
Dim conn As New OleDbConnection(ConfigurationManager.ConnectionStrings("conMyConnection").ConnectionString.ToString) - Note again the "conMyConnection" matches all the way through
- So, if you need to change the location of your database, just change the web.config file and all calls to the database will find the new path.
Happy Databasing
Daniel
No comments:
Post a Comment