Click here to Skip to main content
15,905,867 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to make exe of my C# project which has a mdf database in it. I want an exe that can run on any PC without need to install SQL server.

What I have tried:

I have tried on make setup of my project but i get this error when i install my app on other PCs.
C#
a network-related or instance-specific error occurred while establishing a connection to sql server, The sever was not found or was not accessible. Verify that the instance name is correct and that SQL sever is configured to allow remote connections. (Provider: SQL network intefaces, error 52 - Unable to locate a Local Database runtime installation. Verify that SQL sever Express is Properly installed and that the Local Database runtime feature is enabled
Posted
Updated 24-Nov-16 3:09am

1 solution

The error message tells you what to do:
Quote:
Verify that SQL sever Express is Properly installed and that the Local Database runtime feature is enabled
Detailed instructions can be found at SQL Server 2016 Express LocalDB[^].

Quote:
I want an exe that can run on any PC without need to install SQL server
For read-only access you may have a look at GitHub - improvedk/OrcaMDF: A C# parser for MDF files. Allows you to read tables, metadata and indexes from MDF files without it being attached to a running SQL Server instance.[^].

If you don't want to install LocalDB on the client machines you can use a different database format that can be accessed without a dedicated server process (e.g. using an OleDB provider; but even then you usually have to install that provider).
 
Share this answer
 
Comments
tusifpk 24-Nov-16 9:10am    
I have a simple C# project With some Forms and a mdf database file. I am retrieving and saving data into this database with the help of forms.

I did not install in Ms SQL Server except the compact edition which installs with visual studio 2010.

Now what i want:
1. Make a setup file of this project.

When i install this setup file on any other PC it should connect with the mdf database without giving any error. Should insert, delete and update the records in the database smoothly.
Last thing is that i dont want to install Sql server on other PCs. I want my exe to work standalone. Is it possible?
i have followed some tutorial on internet in which they include the mdf file in the setup project and then build the project to get the setup file. I did the same but the problem is that its works on my PC only not on other
Jochen Arndt 24-Nov-16 9:35am    
Include the "SQL Server 2016 Express LocalDB" in your setup file (the LocalDB packet which is a special - simple to install- version of SQL Server Express).

Each database needs a server or at least some kind of engine to access the database files. With MDF files, this is SQL Server (full, Express, or LocalDB).
So you always have to install some kind of additional software to access database file (if not already present).

If you don't want that you have to choose a database that is supported out-of-the-box with Windows. OleDB and common providers should be installed by default witch newer Windows versions. It supports for example Acccess database files. But OleDB supports only basic database operations.
tusifpk 24-Nov-16 9:44am    
Thanks for your expert opinion. Much Appreciable!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900