Multiple data sources with the same name in different directorys? [modified]
-
Hello, I am new to C# and I writing an application that uses an Access database. It works fine I can do almost everything I need to do with that database. The database represents one object, lets say "House" for example. The tables represent the different rooms in the house. The items in each room fill the cells in the table. The problem I am having is that there are several databases "houses", each in their own directory. They each have the same file name. The databases identical except for the data. I want to be able to switch back and forth through them. How can I programatically switch from one Access database in folder A to another Access database in folder B? "House" database name and "Room" tables are just an example. Any and all help would be greatly appreciated. Thank you Kio
modified on Friday, July 24, 2009 9:42 PM
-
Hello, I am new to C# and I writing an application that uses an Access database. It works fine I can do almost everything I need to do with that database. The database represents one object, lets say "House" for example. The tables represent the different rooms in the house. The items in each room fill the cells in the table. The problem I am having is that there are several databases "houses", each in their own directory. They each have the same file name. The databases identical except for the data. I want to be able to switch back and forth through them. How can I programatically switch from one Access database in folder A to another Access database in folder B? "House" database name and "Room" tables are just an example. Any and all help would be greatly appreciated. Thank you Kio
modified on Friday, July 24, 2009 9:42 PM
Kiotaya wrote:
The tables represent the different rooms in the house. The items in each room fill the cells in the table.
Why do you need a different table for each room ?
Kiotaya wrote:
The problem I am having is that there are several databases(houses), each in their own directory
Your approach seems broken. Why not have a houses table and a rooms table ?
Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
-
Kiotaya wrote:
The tables represent the different rooms in the house. The items in each room fill the cells in the table.
Why do you need a different table for each room ?
Kiotaya wrote:
The problem I am having is that there are several databases(houses), each in their own directory
Your approach seems broken. Why not have a houses table and a rooms table ?
Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
-
Im sorry, I should have explained the name "House" is an example. The actual database name is "Merchant". How do I switch from Access database in folder A to Access database in folder B?
change your connection string or create a new connection to the other database
Never underestimate the power of human stupidity RAH
-
change your connection string or create a new connection to the other database
Never underestimate the power of human stupidity RAH
-
Thank you for your response but neither of these options are practicle. I need to be able to programaticlly switch from one database to another.
Kiotaya wrote:
neither of these options are practicle
How on earth do you expect to change the database if you won't change/create another connection. Create a connection to database A called connA use it to do something create another connection to database B called connB use it to do something in the other database.
Never underestimate the power of human stupidity RAH
-
Kiotaya wrote:
neither of these options are practicle
How on earth do you expect to change the database if you won't change/create another connection. Create a connection to database A called connA use it to do something create another connection to database B called connB use it to do something in the other database.
Never underestimate the power of human stupidity RAH
That will not work. I need to know how to switch between databases programatically. All the databases have the same name and tables. Also I may be adding more merchants in the future. I do not want to have to go back and recompile the code everytime I add another merchant. I would appreciate it of someone could help me with this or point me in the direction of an article that may help answer this. Thanks Kio
-
That will not work. I need to know how to switch between databases programatically. All the databases have the same name and tables. Also I may be adding more merchants in the future. I do not want to have to go back and recompile the code everytime I add another merchant. I would appreciate it of someone could help me with this or point me in the direction of an article that may help answer this. Thanks Kio
You can't have one connection to many databases. (At least with Access.) Having multiple connections is a way to do this programatically. How about a Dictionary of connections? Otherwise you'll need to explain what you need more clearly.
-
You can't have one connection to many databases. (At least with Access.) Having multiple connections is a way to do this programatically. How about a Dictionary of connections? Otherwise you'll need to explain what you need more clearly.
Thanks but I figured it out myself. -You can't have one connection to many databases. (At least with Access.)- -How about a Dictionary of connections?- -Otherwise you'll need to explain what you need more clearly.- By using the "xxx.exe.config" file you can change the directory your connection is pointing to. This way I do not have to recompile code everytime I want to add a merchant.
-
Thanks but I figured it out myself. -You can't have one connection to many databases. (At least with Access.)- -How about a Dictionary of connections?- -Otherwise you'll need to explain what you need more clearly.- By using the "xxx.exe.config" file you can change the directory your connection is pointing to. This way I do not have to recompile code everytime I want to add a merchant.
What so you are going to add a new merchant to your config file every time you expand your base. Your design sucks (sticking with a good CP theme) you need to take a look at the design of your entire solution. I wrote the above and then sat back and thought maybe it works for you, I'm glad you found a solution although it is not one I would use.
Never underestimate the power of human stupidity RAH
-
Thanks but I figured it out myself. -You can't have one connection to many databases. (At least with Access.)- -How about a Dictionary of connections?- -Otherwise you'll need to explain what you need more clearly.- By using the "xxx.exe.config" file you can change the directory your connection is pointing to. This way I do not have to recompile code everytime I want to add a merchant.
Well why didn't you say that's what you wanted to do in the first place?! :confused: