How do I get SQL 2008 Express into the deployment?

Answered How do I get SQL 2008 Express into the deployment?

  • Tuesday, April 12, 2011 8:12 PM
     
     

    Soon I'll start work on a major project; to re-write an old VB6 app into a WPF app.  One of the things that must go into this is a SQL Server 2008 Express database.  I've done one other WPF app, which is distributed to users desktops via ClickOnce, and that has worked great.  However, it doesn't have any local data store.  In trying to figure out how ClickOnce does things, where it puts the executables, etc, but I've no clue.  They don't appear to me to be under Program Files\<Application Name> or anything like that.  But I do assume that all files of an application are "all together", wherever it is.  When I make changes to my first WPF app and publish it to the file share, all of my users' applications update themselves.  Way cool.

    But what do I do with an application that relies on a SQL Express data store?  I certainly do not want it to replace the SQL Express file, when I push out a new version of my app, for example.  That could literally be disasterous for us!  It would be much better if the SQL Express database was in something like the user's My Documents folder.  That when they run the setup to install my program for the first time, it install the SQL Express database where it will permanently reside, and that all subsequent updates leave the SQL Express database alone.  How do I do that?


    Rod

All Replies

  • Wednesday, April 13, 2011 8:59 AM
    Moderator
     
     Answered

    Hi Rod at Work,

    The database file will be deployed to the "Local\Apps\2.0\Data" directory, and in my test project the database file will be not updated when you update your application.

    The application will be installed to the "Local\Apps\2.0" directory, in windows 7 it is like this:

    "C:\Users\[username]\AppData\Local\Apps\2.0"

    For more about this path information, you can reference this article:

    http://blogs.msdn.com/b/rprabhu/archive/2005/06/29/433979.aspx

     

    Have a nice day!


    Mike [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

  • Thursday, April 14, 2011 2:01 AM
    Moderator
     
     Answered

    Hi Rod,

    I thik this will be helpful to you. It explains how to include data in your deployment, and move it before you use it. This keeps it safe from accidentally deploying a replacement (which will happen if you so much as even open the SQL Express database in your project), and you know where the dang thing is.

    http://robindotnet.wordpress.com/2009/08/19/where-do-i-put-my-data-to-keep-it-safe-from-clickonce-updates/

    You can publish SQL Express as a prerequisite to your ClickOnce application, by the way, by selecting it in the Prerequisites dialog. If you want the newest version (SQL Express 2008 R2), you can create your own prerequisite package for it (Microsoft does not provide it) by following the instructions and retrieving the files from this article:

    http://robindotnet.wordpress.com/2011/02/06/how-about-a-bootstrapper-package-for-sqlserver-express-2008-r2/

    ClickOnce applications do not deploy to Program Files. ClickOnce apps run with no administrative privileges, and writing to Program Files requires that. It puts the files under the user's profile in a folder structure starting with Apps\2.0\.

    RobinDotNet


    Click here to visit my ClickOnce blog!
    Microsoft MVP, Client App Dev
  • Monday, April 18, 2011 3:28 PM
    Moderator
     
     

    Hi Rod,

    I am writing to check the status of the issue on your side. 

    What about this problem now? 

    Would you mind letting us know the result of the suggestions?

    Best wishes,


    Mike [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

  • Tuesday, May 10, 2011 7:56 PM
     
     

    Hi Rod,

     

    I am writing to check the status of the issue on your side. 

    What about this problem now? 

    Would you mind letting us know the result of the suggestions?

    Best wishes,

     


    Mike [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.


    I'm going to start experimenting by creating a SQL Express database in "Local\Apps\2.0" and seeing how it does with a simple app.
    Rod
  • Thursday, May 12, 2011 6:15 AM
    Moderator
     
     

    I will go on following up if you have any update on your experimental.

     

    Best wishes,


    Mike [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

  • Thursday, May 12, 2011 8:40 PM
     
     
    Mike, quick question.  When using "Local\Apps\2.0", I assume I should create a new folder under that, say "RodsApp" to put my SQL Express database into.  Correct?
    Rod
  • Friday, May 13, 2011 2:43 AM
    Moderator
     
     

    It dependent your design.

    The files can be placed where you would like, it just a common file.

    But, we suggest you just let the ClickOnce to deploy/manage the databases files to the matched directory.

    Since we don't know how much problems will be given to you, if you do it yourself instead of just let ClickOnce go.

     

    Best wishes,


    Mike [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.