Change DB connection at runtime?

shanew

New member
Joined
Oct 2, 2009
Messages
3
Programming Experience
1-3
I’m building an app that needs to have the ability to change OLEDB server at startup depending on what is set in the applications configuration file.
The Tables in the database will stay the same but I have 3 different types of connectivity I would like.
1) SQL Server.
2) Access local file (c:\APPFILES\DB\APPDB.MDB)
3) Access remote file (\\Servername\sharename\APPDB.MDB)

So in my App I have a dataset named:
MyAppDataSet
In the main form it the load as:
Line of code: Me.CarsTableAdapter.Fill(Me.MyAppDataSet.Cars)
("Cars" is the Table im conecting to in the DB)

Should or could I just make 3 dataset connections and then replace this line art runtime?

I kind of need the connection strings to be flexible so that if the server name changes.

Not sure of the best way to do this, any help would be grate!
Thanks
Shane
 
Back
Top