Unable to access Microsoft SQL of an exe (standalone app) in another system

CEO 136 Reputation points
2021-11-07T10:06:41.443+00:00

Laptop 1.
My codes run well as expected without any error. It has a GUI with data stored in the database.

I created exe (standalone) files which run very well. When I copy these exe files created in Laptop 1 to laptop 2, they work fine. Laptop 1 and Laptop 2 have Microsoft SQL server and Mysql server.

Laptop 2:

The same codes in Laptop 1 run well in Laptop 2. When I create exe files in Laptop 2, they run fine and connect to the database well. But when I copy the created exe files to other systems, they run well but don't get connected to the database.

I've not tried copying them to Laptop 1 because presently I'm not with Laptop 1. I copied the exe files created in Laptop 2 to Laptop 3 (Laptop 3 doesn't have any SQL server), they run fine but don't get connected to the database.

I shared the exe files to some of my friends who run them on their systems too. The apps open well but don't get connected to the database server.

Does anyone know the reason for this?

Azure SQL Database
SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,776 questions
{count} votes

Accepted answer
  1. Erland Sommarskog 101.4K Reputation points MVP
    2021-11-08T08:22:32.767+00:00

    The database server is in the computer I used in creating the standalone exe file.

    If so, the computers running the application needs to have access to the computer where you created the application, and the connection string must point to that computer.

    You need to understand that SQL Server applications are client/server applications. Your standalone program is the client. There is nothing in that program which includes SQL Server. SQL Server always runs in a separate process. And in many cases it runs on a separate computer from the application. You can imagine an application used in a corporation with thousands of users. The users have the application on their laptops, but there is only one instance of SQL Server running on a server somewhere in the IT Centre.

    Presumably the idea in your case is that user should have the database on his or her computer, but then that computer must have SQL Server installed. You could include this in the installation of your application.

    If you want all bundled in a single executable, there are other DB alternatives that are more lightweight and better suited for this low-end part of the scale. SQLite, for instance, is quite popular.

    0 comments No comments

0 additional answers

Sort by: Most helpful