question

CEO-8149 avatar image
0 Votes"
CEO-8149 asked TomPhillips-1744 edited

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

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?

sql-server-generalazure-sql-database
· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I'd rather turn the question around: why would they connect in the first place?

Where is the database for the application located? You have tagged azure-sql-database, so I am right to assume the database in question is an Azure SQL Database?

How does your connection string look like?

0 Votes 0 ·

Thanks for your response. The database server is in the computer I used in creating the standalone exe file. As a standalone file, it is supposed to run on any system with all the libraries and drivers used in writing the script as all have been packed or frozen into the exe file to enable it run anywhere as a pack.

Making it an exe file gives it the privilege to run on others systems even though they do not have the database server installed in them.

Why does Microsoft SQL give one a tough time?

@AmeliaGu-msft

@ErlandSommarskog

0 Votes 0 ·

SQL Server is a separate service and installation. Compiling to a "standalone .exe" does NOT create an .exe with the SQL Server service included inside it.

0 Votes 0 ·

Hi CEO-8149,

In addition, are there any error message when you connected to SQL Server?
Could you please try to connect to SQL Server using SSMS and see if there are any error messages?

Best Regards,
Amelia


0 Votes 0 ·

1 Answer

ErlandSommarskog avatar image
0 Votes"
ErlandSommarskog answered

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.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.