Publish C# application with SQL Server database

524 Views Asked by At

My application does basic CRUD operations over an external .mdf file. The database file is created separately in SSMS. On my PC, everything works perfectly fine. When I install it on someone else's computer, it refuses to connect to the database. The other PC also has the same database at the exact same location.

The connection string I am using is (in app.config):

conString=Data Source =.\sqlexpress; Initial Catalog = dbName;
Integrated Security = True; Pooling = False

In my code:

dbConnection = new SqlConnection(Settings.Default.conString);

The other PC has SQL Server installed as well. Tried going through almost all the results but almost all of them suggest either

  1. Adding the existing database with the project. I can't seem to do that because when I try that I get an error:

    permission denied

  2. I can't rewrite the whole code with a service based database pre-attached to it.

0

There are 0 best solutions below