• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 13. Using Data Access Pages > Programmatically Change the Connection St...

13.6. Programmatically Change the Connection String for All Pages in a Database

13.6.1. Problem

You don't want to rely on yet another extra file, such as the data connection file, to determine how your application is supposed to work. But you also don't want to manually change the ConnectionString property of each page every time you need to point to a different data source.

13.6.2. Solution

As long as you can count on having Access available every time you need to point to a different data source, it's easy to change the ConnectionString property of every page programmatically. You'll need to iterate through the collection of pages and change the ConnectionString property. Note that ConnectionString is a property of the DataSource control for the page; you can refer to the DataSource object as MSOSDC.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint