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. .NET (Core and Framework)
  4. How to connect multiple computers to the same database?

How to connect multiple computers to the same database?

Scheduled Pinned Locked Moved .NET (Core and Framework)
databasewinformstutorialquestiondiscussion
14 Posts 8 Posters 2 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.
  • Richard DeemingR Richard Deeming

    Maciej Los wrote:

    For further details, please see Richard's MacCutchan answer.

    Really? I know I had a birthday recently, but RMC's still got a few years on me. :laugh:


    "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

    M Offline
    M Offline
    Maciej Los
    wrote on last edited by
    #5

    Oooops! :doh: :sigh: :doh: I owe you a box of good polish :beer:

    Richard DeemingR 1 Reply Last reply
    0
    • M Maciej Los

      Oooops! :doh: :sigh: :doh: I owe you a box of good polish :beer:

      Richard DeemingR Offline
      Richard DeemingR Offline
      Richard Deeming
      wrote on last edited by
      #6

      Maciej Los wrote:

      good polish :beer:

      Any recommendations beyond Zywiec Porter? It's been a few years since my last visit. :)


      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

      "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

      M 1 Reply Last reply
      0
      • Richard DeemingR Richard Deeming

        Maciej Los wrote:

        good polish :beer:

        Any recommendations beyond Zywiec Porter? It's been a few years since my last visit. :)


        "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

        M Offline
        M Offline
        Maciej Los
        wrote on last edited by
        #7

        Sounds like you are a fan of dark beer... Yes, there's few other brands, like: [Okocim](https://pl.wikipedia.org/wiki/Okocim\_(piwo)), [Łomża](https://pl.wikipedia.org/wiki/Łomża\_(piwo)) and few less known companies (small, local breweries). Cheers! Maciej

        Richard DeemingR 1 Reply Last reply
        0
        • M Maciej Los

          Sounds like you are a fan of dark beer... Yes, there's few other brands, like: [Okocim](https://pl.wikipedia.org/wiki/Okocim\_(piwo)), [Łomża](https://pl.wikipedia.org/wiki/Łomża\_(piwo)) and few less known companies (small, local breweries). Cheers! Maciej

          Richard DeemingR Offline
          Richard DeemingR Offline
          Richard Deeming
          wrote on last edited by
          #8

          Thanks - I'll keep an eye out for them. Although I might avoid the piwo bezalkoholowe version. :-D


          "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

          "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

          1 Reply Last reply
          0
          • S SebGM25

            Hi guys, I’m making a Windows Forms application for a company. It needs database management and that kind of things, so I decided that I was going to use Entity Framework based on an SQL database. The thing is, that I don’t know how could it be possible to connect multiple computers to the same database. It is such a small company, that they don’t have internet, so I don’t know how could I achieve this. I thought about having the database file saved in computer A, and computer B and C should connect to it, even through usb cables. I don’t know if this is the best practice, and if it is, how could I do it?

            D Offline
            D Offline
            Dave Kreskowiak
            wrote on last edited by
            #9

            Nobody has mentioned it yet, but networking through USB cables isn't going to work. Use Ethernet or your network doesn't happen in a supportable way.

            Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles.
            Dave Kreskowiak

            1 Reply Last reply
            0
            • S SebGM25

              Hi guys, I’m making a Windows Forms application for a company. It needs database management and that kind of things, so I decided that I was going to use Entity Framework based on an SQL database. The thing is, that I don’t know how could it be possible to connect multiple computers to the same database. It is such a small company, that they don’t have internet, so I don’t know how could I achieve this. I thought about having the database file saved in computer A, and computer B and C should connect to it, even through usb cables. I don’t know if this is the best practice, and if it is, how could I do it?

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #10

              [Configuring SQL Server 2016 Express On LAN For C# Connection String](https://www.c-sharpcorner.com/article/configuring-sql-server-2016-express-on-lan-for-c-sharp-connection-string/)

              It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it. ― Confucian Analects: Rules of Confucius about his food

              1 Reply Last reply
              0
              • M Maciej Los

                Quote:

                I thought about having the database file saved in computer A, and computer B and C should connect to it, even through usb cables. I don’t know if this is the best practice, and if it is, how could I do it?

                Sorry, you're wrong. You need only one database installed on a single computer (let it be computer A). You have to install an SQL server on it and enable remote connections to that SQL server instance. Other computers (B-Z) have to have intalled an application, which connection string refers to SQL server instance on computer A. I'd suggest to get connection string from config file. See: [Connection Strings and Configuration Files | Microsoft Docs](https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/connection-strings-and-configuration-files) For further details, please see Richard's MacCutchan Deeming answer. [EDIT] Sorry, Richard.

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #11

                Thank you, apology accepted. But it was nice being an SQL expert for a while. :laugh:

                1 Reply Last reply
                0
                • Richard DeemingR Richard Deeming

                  You install SQL Server on one computer, and create the database there. All other computers that need to use your database will need to be able to connect to the SQL Server computer, so you'll need to enable remote connections, and possibly add an exception to the Windows firewall. How to configure SQL Server 2005 to allow remote connections[^] You configure your application's connection string to point to the single SQL Server instance, and the computers will all be using the same database. SQL Server connection strings - ConnectionStrings.com[^]


                  "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

                  M Offline
                  M Offline
                  Member 14688122
                  wrote on last edited by
                  #12

                  Make sure that the SQL server on a machine is accessible from all computers you intent the app to work. You also may have to open ports used by the SQL server in the firewall. You can then update the connection string to connect to the SQL instance.

                  A 1 Reply Last reply
                  0
                  • M Member 14688122

                    Make sure that the SQL server on a machine is accessible from all computers you intent the app to work. You also may have to open ports used by the SQL server in the firewall. You can then update the connection string to connect to the SQL instance.

                    A Offline
                    A Offline
                    amrinde
                    wrote on last edited by
                    #13

                    First of all you have to change localhost with the host name or with the ip of the sql server hosting pc. then you have to enable tcp/ip on the sql server Configuration Manager on the hosting pc then go to SQL Server Network Configuration and click on Protocols for SQLEXPRESS. Then you will see that TCP/IP is disabled. Double Click on TCP/IP and select yes to enabled.

                    1 Reply Last reply
                    0
                    • Richard DeemingR Richard Deeming

                      You install SQL Server on one computer, and create the database there. All other computers that need to use your database will need to be able to connect to the SQL Server computer, so you'll need to enable remote connections, and possibly add an exception to the Windows firewall. How to configure SQL Server 2005 to allow remote connections[^] You configure your application's connection string to point to the single SQL Server instance, and the computers will all be using the same database. SQL Server connection strings - ConnectionStrings.com[^]


                      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

                      M Offline
                      M Offline
                      Member_14689323
                      wrote on last edited by
                      #14

                      It's generally a bad idea to hard code such stuff in your application. Normally, application settings and connection strings are placed in the application's configuration file (in the ConnectionStrings section). Just like with all strings, you could build your connectionstring from dynamic parts (variables, settings, etc.) and then pass that generated connectionstring to the SqlConnection constructor. Again, to make those separate parts configurable without hard coding them in your application, you might want to add them to your application's configuration file (in the AppSettings section). But IMHO this is an overly complex solution in most scenarios. Putting the entire connectionstring in the ConnectionStrings section is more straightforward (and more flexible). Anyway, again, to make your application configurable, you might use your application's configuration file (App.config or Web.config), you need to add a reference to System.Configuration in your project's .NET Framework dependencies and use the AppSettings and ConnectionStrings properties of the System.Configuration.ConfigurationManager class. (Of course, there are more ways to make your application configurable. But using the application configuration file is one of the most straightforward solutions.) Courtesy: Stack Overflow

                      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