OleDbConnection DataSource configuration in code

  • Thread starter Thread starter dave
  • Start date Start date
D

dave

Hello All -

I've got a couple of .NET Windows forms that have associated
OleDbDataAdapters and OleDbConnection. What is the best approach to
implementing a method for configuring the location of the underlying
data source.

I would like to be able to toggle (in code) between Development, Test,
and Production databases. Lets say for example:

dev db: "c:\databases\dev\myDB.mdb"
test db: "s:\databases\test\myDB.mdb"
prod db: "s:\databases\prod\myDB.mdb"

It seems like I need to set the connection's DataSource property prior
to establishing a connection. But if the connection is associated
with the form, how can I configure the connection in code prior to
loading the form?

Thanks!
Dave
 
Why dont u just store connection info in a configuration file? You can
convineantly have three key values (dev, test, prod) in your appSettings
node in the config file and toggle between them as needed in your code using
ConfigurationSettings.AppSettings function.
 
Back
Top