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 connections

Multiple connections

Scheduled Pinned Locked Moved C#
helpcsharpdatabasetutorialannouncement
5 Posts 3 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.
  • M Offline
    M Offline
    Micu Radu
    wrote on last edited by
    #1

    I have made a SnippetDB application like CodeLib Access version that fish made it http://myweb.hinet.net/home4/s630417/ My problem is i want to use multiple access databases and I don not know how to store my connections or how to use it or simple how to start For only one db is easy and my app is working but i can not figure how to do it for more. Creating a db programaticly is not hard so pls help me with code if possible thx... (o)(o)

    C L 2 Replies Last reply
    0
    • M Micu Radu

      I have made a SnippetDB application like CodeLib Access version that fish made it http://myweb.hinet.net/home4/s630417/ My problem is i want to use multiple access databases and I don not know how to store my connections or how to use it or simple how to start For only one db is easy and my app is working but i can not figure how to do it for more. Creating a db programaticly is not hard so pls help me with code if possible thx... (o)(o)

      C Offline
      C Offline
      CheckDude
      wrote on last edited by
      #2

      I might be missing something here, but have you tried making each connection its own object? Instantiating several database connections as their own objects is the way that I get to multiple database connections. I apologize if I am missing something and this is a stupid answer. Bob Robey

      1 Reply Last reply
      0
      • M Micu Radu

        I have made a SnippetDB application like CodeLib Access version that fish made it http://myweb.hinet.net/home4/s630417/ My problem is i want to use multiple access databases and I don not know how to store my connections or how to use it or simple how to start For only one db is easy and my app is working but i can not figure how to do it for more. Creating a db programaticly is not hard so pls help me with code if possible thx... (o)(o)

        L Offline
        L Offline
        Luis Alonso Ramos
        wrote on last edited by
        #3

        Just store the different connection strings, and create a connection every time you need it. .NET connection pooling will find out if there's already another "closed" open connection (when you close it, it's not actually closed until some time later) and reuse it. The connection string must be identical for a connection to be reused, but if you have 5 different databases, you'll have 5 pools. -- LuisR


        Luis Alonso Ramos Intelectix - Chihuahua, Mexico Not much here: My CP Blog!

        M 1 Reply Last reply
        0
        • L Luis Alonso Ramos

          Just store the different connection strings, and create a connection every time you need it. .NET connection pooling will find out if there's already another "closed" open connection (when you close it, it's not actually closed until some time later) and reuse it. The connection string must be identical for a connection to be reused, but if you have 5 different databases, you'll have 5 pools. -- LuisR


          Luis Alonso Ramos Intelectix - Chihuahua, Mexico Not much here: My CP Blog!

          M Offline
          M Offline
          Micu Radu
          wrote on last edited by
          #4

          "connection string must be identical for a connection to be reused" Eaven the db names should be the same? The thing is that I have a app with a TreeView and the treeview is populated with all db names and then in each db node with some info from the db, and when i click a node the app will use to get info from the selected db... Until now this is the method I have used changein the string but when I create a new DB and try to insert it in the tre view i do the .clear() thing from the tree and the try to rebuild it again... and some errors apear i will be back with code and error text... Sorry for my BAD BAD english... Thx

          L 1 Reply Last reply
          0
          • M Micu Radu

            "connection string must be identical for a connection to be reused" Eaven the db names should be the same? The thing is that I have a app with a TreeView and the treeview is populated with all db names and then in each db node with some info from the db, and when i click a node the app will use to get info from the selected db... Until now this is the method I have used changein the string but when I create a new DB and try to insert it in the tre view i do the .clear() thing from the tree and the try to rebuild it again... and some errors apear i will be back with code and error text... Sorry for my BAD BAD english... Thx

            L Offline
            L Offline
            Luis Alonso Ramos
            wrote on last edited by
            #5

            Well, then just make sure that everytime the same node is selected, the same connection string is built. You'll have connection pooling working for each different connection string, but in you scenario, I think that's the best you can do. -- LuisR


            Luis Alonso Ramos Intelectix - Chihuahua, Mexico Not much here: My CP Blog!

            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