Stefan Hariton
Stefan Hariton

Reputation: 357

C# Windows Form Application is not publishing local database (.mdf)

I've made an Windows Form Application in Visual Studio with a local database, and as always it works fine when developing it but if I publish it and try to run on a different computer, it doesn't work.

Here is my connection string in app.config:

    <connectionStrings>
    <add name="Fitness_Club.Properties.Settings.FitnessClubConnectionString"
        connectionString="Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\FitnessClub.mdf;Integrated Security=True;Connect Timeout=1"
        providerName="System.Data.SqlClient" />
</connectionStrings>

These are my application files Here are my application files This is the error I get on other computers! enter image description here

I'm struggling with these already 2 days and can't come to an end.

What I need to do to run my application on other computers?

Upvotes: 0

Views: 835

Answers (1)

user1400995
user1400995

Reputation:

The problem is clearly on the connection. To do a quick test without involving your application, I would create a new connection string on your remote pc. To do that, create an empty text file, change the extension from .txt to .udl.Then, click the .udl file and will open the Data Link Properties wizard.From there and on configure and test the connection to your database server. Once you do that, you know your connection string is correct. Then copy the connection string back to your app.config and run the application...check here for more info https://msdn.microsoft.com/en-us/library/e38h511e%28v=vs.71%29.aspx

Upvotes: 1

Related Questions