简体   繁体   中英

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 这是我的申请文件 This is the error I get on other computers! 在此处输入图片说明

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM