How to Run C# Application On Multiple Computers With Single Database in Urdu/Hindi
Table of Contents
Introduction
This tutorial will guide you through the process of running a C# application on multiple computers while connecting to a single database. This is especially useful for businesses or teams that need to access the same data simultaneously. We will cover the necessary configurations and steps to ensure your application runs smoothly across different machines.
Step 1: Set Up the SQL Server
- Install SQL Server: Ensure that SQL Server is installed on a central machine that will act as your database server.
- Open SQL Server Configuration Manager:
- For SQL Server 2016, run:
C:\Windows\SysWOW64\SQLServerManager13.msc
- For SQL Server 2014, run:
C:\Windows\SysWOW64\SQLServerManager12.msc
- For SQL Server 2012, run:
C:\Windows\SysWOW64\SQLServerManager11.msc
- For SQL Server 2008, run:
C:\Windows\SysWOW64\SQLServerManager10.msc
- For SQL Server 2016, run:
- Enable TCP/IP Protocol:
- In the Configuration Manager, locate the SQL Server Network Configuration.
- Click on "Protocols for [Your SQL Server Instance]".
- Right-click on TCP/IP and select Enable. This allows remote connections.
Step 2: Configure SQL Server for Remote Access
- Open SQL Server Management Studio (SSMS).
- Connect to your Database Instance.
- Create a new login for users:
- In the Object Explorer, expand Security, then Logins.
- Right-click on Logins and select New Login.
- Enter a login name and set the password.
- Assign Database Access:
- Under User Mapping, select the database you want users to access and assign the necessary roles (e.g., db_datareader, db_datawriter).
Step 3: Adjust Windows Firewall Settings
- Open Windows Firewall:
- Go to Control Panel > System and Security > Windows Defender Firewall.
- Allow App Through Firewall:
- Click on "Allow an app or feature through Windows Defender Firewall".
- Ensure that SQL Server (sqlservr.exe) is allowed for both private and public networks.
- Add Port for SQL Server:
- In the Firewall settings, click on "Advanced settings".
- Create a new inbound rule to allow TCP port 1433 (default SQL Server port).
Step 4: Modify C# Application Connection String
- Locate your Connection String:
- Find the part of your C# application where the database connection string is defined.
- Update the Connection String:
- Change the connection string to point to the server's IP address or hostname:
string connectionString = "Server=YOUR_SERVER_IP;Database=YOUR_DATABASE;User Id=YOUR_USER;Password=YOUR_PASSWORD;";
- Change the connection string to point to the server's IP address or hostname:
Step 5: Deploy the Application on Client Machines
- Copy the Application:
- Transfer your C# application to each client machine.
- Ensure .NET Framework is Installed:
- Check that the required version of the .NET Framework is installed on each client machine.
- Run the Application:
- Launch the application on each client and verify that it connects to the central database as expected.
Conclusion
By following these steps, you will be able to run a C# application on multiple computers with a single database connection. Key actions include setting up SQL Server for remote access, configuring firewall settings, and updating the connection string in your application. For further enhancements, consider implementing security measures such as encryption for sensitive data transmissions. If you encounter issues, double-check each step to ensure proper configuration.