简体   繁体   中英

WPF connection string for .mdf file database

I have a problem with publish of my WPF application.

Database doesn't attach by project, and located in folder Debug , and connection string is :

<connectionStrings>
    <add name="DataFormConnection"
         connectionString="Server=(localdb)\v11.0; Integrated Security=True;AttachDBFilename=|DataDirectory|\DBT.mdf; Connection Timeout = 30" 
         providerName="System.Data.SqlClient" />
</connectionStrings>

Accession takes place after this string

In VS2012 it works great, but when I publish the application, database is not in the folder AppFiles .

Just trying to publish database through installshield but also to no avail.

How all the same right to register the connection string? Thanks!

In Solution Explorer, right click your database file and select Properties. Make sure the "Copy to Output Directory" item is selected as "Copy always".

Now, every time you compile your application, your original database file is copied to the Debug folder.

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