my Sql progrom refuses to work on other computers

Lowkey Mori Ougai 1 Reputation point
2022-04-13T21:43:58.6+00:00

ok so my question is how do i get my sql server to be displayed properly for other people computers it seems to not have been working when i set up the database with the local connection so i connected to a database i created in sql server manager and added the connection string that it had but still didnt work and gave me an error saying to make sure my instance name is correct and that I need to check if i have remote connections turned on and i do but it still doesnt work. it seems to not want to work when i type display_data(); on the form load on a button and doesnt want to display on the grid view. please help ive been working on this project for quite sum time and i dont want to discard it considering it would make me lose the drive to code.

the string im using is
(@"Data Source = DESKTOP - UH0ETGE\SQLEXPRESS; Initial Catalog = DB_Server2; Integrated Security = True");

Windows Forms
Windows Forms
A set of .NET Framework managed libraries for developing graphical user interfaces.
1,865 questions
SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,099 questions
0 comments No comments
{count} votes

4 answers

Sort by: Most helpful
  1. Naomi 7,366 Reputation points
    2022-04-13T21:55:44.2+00:00

    You're using Windows Authentication, so only you can connect to your laptop and SQL Server Express

    0 comments No comments

  2. Erland Sommarskog 103.8K Reputation points MVP
    2022-04-13T22:01:01.017+00:00

    Well, Data Source = DESKTOP - UH0ETGE\SQLEXPRESS, that refers to that particular machine. I assume that this is your laptop.

    I don't know exactly what you mean with "other people computers", but presumably you want them to run against their own database, so they would need to install SQL Express on their machines. That part of the connection string should be changed to read Data Source = (localhost)\SQLEXPRESS.

    If your intention is that people really should connect to your laptop, I urge you to think twice. You don't want that. If you want people to a central computer, you need to put that name in the connection string. If that is also in instance of SQL Server Express Edition, you will need to use SQL Server Configuration Manager to enable remote connections, as this is disabled by default for Express Edition. You may also have to open ports in firewalls.


  3. tibor_karaszi@hotmail.com 4,306 Reputation points
    2022-04-14T07:01:40.963+00:00

    If you want other computers to be able to access your SQL Server, you need to make it accessible to the network. You use the SQL Server Configuration Manager tool and enable the "TCP/IP" protocol. Now your SQL server listens to that protocol. Take a note on the port number (re-start your SQL Server and then check) and make sure that there is no firewall in between that block access to that port on your computer.

    0 comments No comments

  4. AmeliaGu-MSFT 13,961 Reputation points Microsoft Vendor
    2022-04-14T09:36:10.513+00:00

    Hi LowkeyMoriOugai-3263,

    In addition, for named instance, if the sql server is listening on the dynamic port, please make sure the SQL Server browser is running, and UDP 1434 is opened in the firewall. If sql server is listening on the specific port, please make sure you have added firewall rule for the port.
    Please refer to https://learn.microsoft.com/en-us/sql/sql-server/install/configure-the-windows-firewall-to-allow-sql-server-access?view=sql-server-ver15 and https://learn.microsoft.com/en-us/sql/database-engine/configure-windows/configure-a-server-to-listen-on-a-specific-tcp-port?view=sql-server-ver15 which might be helpful.

    Best Regards,
    Amelia

    0 comments No comments