locked
How to create an installation that contains a sql server database RRS feed

  • Question

  • I Created an application in c# with Visual Studio 2008, and i'am using SQL Server 2012 for implement databases for the applications.

    My Questions are :

    1) How can i create an installation that contains the database without using the atach databse method.

    2) If the user who gonna install my application has a diffrent sql server name how can i change the sql connection string in my programme to the right one for the user.

    Please F1 ! F1 !

    Thursday, August 9, 2012 5:31 PM

Answers

  • There are a couple of ways that you can do this.

    First, instead of attach, you can either use a backup/restore or have a set of CSV files that are imported into the database after your database creating script is run.

    Now ... for the harder part ...

    How you go about doing this is going to depend on how you are doing the setup. If you are using a Visual Studio Deployment Project, you can create an installer class that will prompt the user for the connection string information. You would then use code in this class to do the database creation/import or restore as well as edit the config file.

    If you are using WIX, there are WIX extensions that will create databases. There is also, IIRC, and extension that will edit Xml files. Finally, you can also create your own extension.

    The Visual Studio deployment project is easier. WIX is more powerful and flexible but can be rather intimidating to learn and get started with.


    DevBiker (aka J Sawyer)
    Microsoft MVP - Sql Server (StreamInsight)


    Ruminations of J.net


    If I answered your question, please mark as answer.
    If my post was helpful, please mark as helpful.

    • Proposed as answer by Lisa Zhu Tuesday, August 14, 2012 2:42 AM
    • Marked as answer by Lisa Zhu Thursday, August 16, 2012 10:37 AM
    Thursday, August 9, 2012 5:51 PM
  • A quick search on Bing turned up: http://msdn.microsoft.com/en-us/magazine/cc163919.aspx and http://techbrij.com/145/install-sql-server-database-with-visual-studio-setup.

    DevBiker (aka J Sawyer)
    Microsoft MVP - Sql Server (StreamInsight)


    Ruminations of J.net


    If I answered your question, please mark as answer.
    If my post was helpful, please mark as helpful.


    • Edited by DevBiker Friday, August 10, 2012 12:50 PM
    • Proposed as answer by Lisa Zhu Tuesday, August 14, 2012 2:46 AM
    • Marked as answer by Lisa Zhu Thursday, August 16, 2012 10:37 AM
    Friday, August 10, 2012 12:48 PM

All replies

  • There are a couple of ways that you can do this.

    First, instead of attach, you can either use a backup/restore or have a set of CSV files that are imported into the database after your database creating script is run.

    Now ... for the harder part ...

    How you go about doing this is going to depend on how you are doing the setup. If you are using a Visual Studio Deployment Project, you can create an installer class that will prompt the user for the connection string information. You would then use code in this class to do the database creation/import or restore as well as edit the config file.

    If you are using WIX, there are WIX extensions that will create databases. There is also, IIRC, and extension that will edit Xml files. Finally, you can also create your own extension.

    The Visual Studio deployment project is easier. WIX is more powerful and flexible but can be rather intimidating to learn and get started with.


    DevBiker (aka J Sawyer)
    Microsoft MVP - Sql Server (StreamInsight)


    Ruminations of J.net


    If I answered your question, please mark as answer.
    If my post was helpful, please mark as helpful.

    • Proposed as answer by Lisa Zhu Tuesday, August 14, 2012 2:42 AM
    • Marked as answer by Lisa Zhu Thursday, August 16, 2012 10:37 AM
    Thursday, August 9, 2012 5:51 PM
  • i sisn't understund isn't there any tutorial that shows me how to do it ?
    Thursday, August 9, 2012 10:16 PM
  • A quick search on Bing turned up: http://msdn.microsoft.com/en-us/magazine/cc163919.aspx and http://techbrij.com/145/install-sql-server-database-with-visual-studio-setup.

    DevBiker (aka J Sawyer)
    Microsoft MVP - Sql Server (StreamInsight)


    Ruminations of J.net


    If I answered your question, please mark as answer.
    If my post was helpful, please mark as helpful.


    • Edited by DevBiker Friday, August 10, 2012 12:50 PM
    • Proposed as answer by Lisa Zhu Tuesday, August 14, 2012 2:46 AM
    • Marked as answer by Lisa Zhu Thursday, August 16, 2012 10:37 AM
    Friday, August 10, 2012 12:48 PM