How to connect multiple computers to the same database?
-
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
Oooops! :doh: :sigh: :doh: I owe you a box of good polish :beer:
-
Oooops! :doh: :sigh: :doh: I owe you a box of good polish :beer:
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
-
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
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
-
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
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
-
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?
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 -
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?
[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
-
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.
-
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
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.
-
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.
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.
-
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
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