none
SQL Server Express 2008 engine and database (with sample data) with ClickOnce deployment RRS feed

  • Question

  • I need some help with deploying my application (preferrably using Clickonce).

    I have created a Windows application using C#.  In my development platform, my application, on my workstation with VS 2008, used a SQL Server 2008 database located on a remote server.  My end users will have standalone instances of my application (each user will individually install the application and have their own local database...I want to use SQL Server 2008 Express for this).  Also, I want the sample data that I used for development included in the database that is deployed.

    My question is that could anyone point me to documentation, tutorials, how to, etc. that can walk me through the process of deploying my application with SQL Server Express as a database?  I will prefer to use ClickOnce.

    Any help will be much appreciated.

    Thanks
    Saturday, March 14, 2009 5:43 PM

Answers

  •  

    Hi KNana,

    To create a Sql Server instance you should use "Create Database ...." command. When you use MSI, you can do this in custom action, but when you use ClickOnce, it doesn't support custom action. You should run this command in your application.
    http://msdn.microsoft.com/en-us/library/ms176061.aspx

    To custom each user's connection string, you can put it in a config file, like settings.settings. Anyway, write the connection string into code is not wise. You can leave an empty string there for a new user, or you can put a default string.
    http://msdn.microsoft.com/en-us/library/aa730869(VS.80).aspx

    Since you choose to use ClickOnce, you'd better let the customer do the configuration at the first run. You can put a flag in the config file, once the customer finish all configuration, do not show config window again.

    Do I misunderstand you?

    Sincerely,
    Kira Qian


    Please mark the replies as answers if they help and unmark if they don't.
    • Marked as answer by Kira Qian Friday, March 20, 2009 8:09 AM
    Thursday, March 19, 2009 2:07 AM

All replies

  •  

    Hi KNana,

    You can set Sql Server Express as prerequisite for your application. Add local database file to your project. The following are the step.

    1. Right click your project file and select "Properties", click "Publish" tabpage.
    2. In that tabpage, click "Application Files" button, in the popup window, set your local database file as "DataFile".
    3. Click "Prerequisites" button(just below "Application Files" button). Set Sql Server 2008 Express Edition as prerequisite and click "OK".

    Here is some information about ClickOnce Deployment.
    http://msdn.microsoft.com/en-us/library/t71a733d(VS.80).aspx

    Sincerely,
    Kira Qian


    Please mark the replies as answers if they help and unmark if they don't.
    Tuesday, March 17, 2009 4:18 AM
  • Kira

    Thanks for responding.

    I have followed those steps several times but still no luck.  My latest error is happens when I try to run the setup on the client computer.  It appears that SQLExpress is installed, and according to the Services.msc information, it appears to be running.  However I am getting the following error:

    "Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance.  The connection will be closed."

    My connection string is as follows:

    "Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\BlueDb_Dev.mdf;Initial Catalog=BlueDb_Dev;Integrated Security=True;User Instance=True"

    I have not had any luck so far with searches online for a solution.

    Your help will be greatly appreciated.

    Thanks.
    KNana
    Wednesday, March 18, 2009 2:25 AM
  •  

    Hi KNana,

    That is a database connection error. Does all client meet connection error or just some of them? I think the connection string should not be predefined, you should let each client to config the application at the first time they use it.

    Sincerely,
    Kira Qian


    Please mark the replies as answers if they help and unmark if they don't.
    Wednesday, March 18, 2009 6:00 AM
  • Kira

    How do I accomplish that...allowing each client to configure their own SQL Server Express instance?

    Do I need to do anything on the server side before I collecting the .mdf file e.g. changing/modifying the users on the server?  Do I leave the ConnectionString blank?

    Please provide step-by-step if you can or point me to documentation that speaks to your suggestion.  Even though I do not want the user to do too much, I can certainly live with some one-time configurations being completed by the user.  So your suggestion sounds very interesting to me.

    Thanks for the help so far.

    KNana
    Wednesday, March 18, 2009 10:31 AM
  •  

    Hi KNana,

    To create a Sql Server instance you should use "Create Database ...." command. When you use MSI, you can do this in custom action, but when you use ClickOnce, it doesn't support custom action. You should run this command in your application.
    http://msdn.microsoft.com/en-us/library/ms176061.aspx

    To custom each user's connection string, you can put it in a config file, like settings.settings. Anyway, write the connection string into code is not wise. You can leave an empty string there for a new user, or you can put a default string.
    http://msdn.microsoft.com/en-us/library/aa730869(VS.80).aspx

    Since you choose to use ClickOnce, you'd better let the customer do the configuration at the first run. You can put a flag in the config file, once the customer finish all configuration, do not show config window again.

    Do I misunderstand you?

    Sincerely,
    Kira Qian


    Please mark the replies as answers if they help and unmark if they don't.
    • Marked as answer by Kira Qian Friday, March 20, 2009 8:09 AM
    Thursday, March 19, 2009 2:07 AM
  • Kira

    Thanks for following up on this.

    I have my first successful deployment.

    I changed the User Instance to false, and gave full access to the "Network Service" account to the user's profile account (I will be following up on this with your suggestions to remove this specific setup because of the adverse security impact of that change).

    Your responses have contributed to my better understanding of the problems.

    Thanks again.
    Thursday, March 19, 2009 10:41 AM