SQLExpress can't attach Database using ClickOnce

I've tried to deply my application using ClickOnce. Togheher with the exe I deploy the database file (mdf) that must be attacched to an instance of SQLExpress using the connection string.

If the database reside in the application directory SQLExpress failed to attach the database, if I copy the database file outside the installation dir ie: C:\data it is OK.

How can deploy the database file outside the installation dir or how can I attach the database that reside in the clickonce installation dir using the connection string

Thanks in advance

Alessandro




Answer this question

SQLExpress can't attach Database using ClickOnce

  • Simplify

    Yes, I solved.

    First I deployed the database file under a application subfolder named Database, to be sure that the database will be copied you must mark it as Include/Required in the applications files dialog.

    Second I changed the connection string as follows:

    AttachDBFilename=|DataDirectory|DataBase\DyeMrp_Data.mdf

    Hope this help,



  • j2associates

    Alessandro

    I'm having the same problem. Have you been able to solve this issue

    Erik


  • SQLExpress can't attach Database using ClickOnce