Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Multiple data sources with the same name in different directorys? [modified]

Multiple data sources with the same name in different directorys? [modified]

Scheduled Pinned Locked Moved C#
helpquestioncsharpdatabasetutorial
11 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Kiotaya
    wrote on last edited by
    #1

    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

    C 1 Reply Last reply
    0
    • K Kiotaya

      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

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      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.

      K 1 Reply Last reply
      0
      • C Christian Graus

        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.

        K Offline
        K Offline
        Kiotaya
        wrote on last edited by
        #3

        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?

        M 1 Reply Last reply
        0
        • K Kiotaya

          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?

          M Offline
          M Offline
          Mycroft Holmes
          wrote on last edited by
          #4

          change your connection string or create a new connection to the other database

          Never underestimate the power of human stupidity RAH

          K 1 Reply Last reply
          0
          • M Mycroft Holmes

            change your connection string or create a new connection to the other database

            Never underestimate the power of human stupidity RAH

            K Offline
            K Offline
            Kiotaya
            wrote on last edited by
            #5

            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.

            M 1 Reply Last reply
            0
            • K Kiotaya

              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.

              M Offline
              M Offline
              Mycroft Holmes
              wrote on last edited by
              #6

              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

              K 1 Reply Last reply
              0
              • M Mycroft Holmes

                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

                K Offline
                K Offline
                Kiotaya
                wrote on last edited by
                #7

                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

                P 1 Reply Last reply
                0
                • K Kiotaya

                  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

                  P Offline
                  P Offline
                  PIEBALDconsult
                  wrote on last edited by
                  #8

                  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.

                  K 1 Reply Last reply
                  0
                  • P PIEBALDconsult

                    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.

                    K Offline
                    K Offline
                    Kiotaya
                    wrote on last edited by
                    #9

                    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.

                    M P 2 Replies Last reply
                    0
                    • K Kiotaya

                      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.

                      M Offline
                      M Offline
                      Mycroft Holmes
                      wrote on last edited by
                      #10

                      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

                      1 Reply Last reply
                      0
                      • K Kiotaya

                        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.

                        P Offline
                        P Offline
                        PIEBALDconsult
                        wrote on last edited by
                        #11

                        Well why didn't you say that's what you wanted to do in the first place?! :confused:

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • World
                        • Users
                        • Groups