Database Setup program

Source: Internet
Author: User
Tags exit cdata create database visual studio
Program | data | Database Introduction
Recently done a database installer, this is intended to do with InstallShield X, the results of the D version did not buy, with the Visual Studio.NET with the installation tools can not meet the requirements, and finally have to develop their own.
Design outline
Design a form base class (Wizardform) and, depending on the required installation steps, create different subclasses that inherit from the class, and use a static Hashtable type global variable to hold the parameter values between these installation step forms. Both the installation database and the initialization data are generated using SQL script, which is uniformly stored in a formatted XML file, which is read by the installer through the path specified in the configuration file and intercepts the subsequent script package based on the installed version saved in the registry. After the installation is successful, save the last installed script package version number in the target computer's registry for later upgrades.
Setup uses the configuration file to save the customized information displayed by the installation interface, such as window title, banner picture, default banner title, default body text, and so on, with the details of the configuration file as follows:

<?xml version= "1.0" encodifg= "Utf-8"?>

<configuration>

<appSettings>

<add key= "CompanyName" value= "Sunwu Software Studio"/>

<add key= "ProductName" value= "IMRP"/>

<add key= "Edition" value= "Standard Edition"/>

<add key= "Updatefile" value= "Update.xml"/>

<add key= "Licencefile" value= "EULA.rtf"/>

<add key= "Title" value= "IMRP database Installation"/>

<add key= "BannerText" value= "IMRP database Installation"/>

<add key= "Bannerimagefile" value= ""/>

<add key= "Warningtext" value= "Warning: This computer program is protected by copyright law and international treaties. Unauthorized reproduction or distribution of this program (or any part thereof) will be subject to severe civil and criminal penalties and will be prosecuted to the maximum extent permitted by law. "/>



<add key= "Welcome.bannertext" value= "Welcome to the IMRP Database Setup Wizard"/>

<add key= "Welcome.bodytext" value= Setup will guide you through the steps required to install the IMRP database on your computer. "/>

<add key= "Licence.bannertext" value= "license Agreement"/>

<add key= "Licence.bodytext" value= now please read this License agreement. If you accept the following terms, click Agree, and then click Next. Otherwise, click Cancel to exit the installation. "/>

<add key= "Setting.bannertext" value= "parameter Settings"/>

<add key= "Setting.bodytext" value= Setup will install the database to the following computer.



Specify the user and password for the database system you want to use during the installation process. "/>

<add key= "Confirm.bannertext" value= "Confirm Installation"/>

<add key= "Confirm.bodytext" value= Setup is ready to install the IMRP database on your computer.



Click Next to start the installation ... "/>

<add key= "Processing.bannertext" value= "Installing"/>

<add key= "Processing.bodytext" value= is installing the IMRP database, please wait ... "/>

<add key= "Completed.bannertext" value= "Installation Complete"/>

<add key= "Completed.bodytext" value= installed successfully? MRP database.



Click Finish to exit. "/>

</appSettings>

</configuration>





Screenshot of the interface
I define the database installer to include these steps:


Welcome (Welcome)
Authorization (Licence)
Settings (Setting)
Confirmation (Confirm)
Progress (processing)
Complete (Completed)
Step form screenshots are as follows:

1. Welcome


2. Authorization


3, set up


4. Confirm


5. Progress


6. Complete

Each step corresponds to a form class that inherits from the base class Wizardform, and they set their own banner title and principal text attributes (see configuration file for details) through the relevant settings in the configuration file.


installation files
Setup uses the script package in the installation file to perform database operations, which contains scripts to create the database and each change that needs to be published, and to package the scripts for versioning. The contents of the specific installation files are as follows:

<?xml version= "1.0" encoding= "Utf-8"?>

<database id= "{98a217a6-c1a2-422a-81d8-41c9ec24abb1}" name= "Gmis" version= "1.0" provider= "SQL Server" remark= "" >

<packet name= "Standard" version= "1.0" title= "Standard Edition" remark= "This version has been updated since November 2002. ">

<script title= "CREATE DATABASE" remark= "Create a database of the specified name on the target computer's database server" >

<! [cdata[

IF $Parameters [Dbexist] = 0

BEGIN

CREATE database $Parameters [Database]

End

]]>

</script>



<script title= "Open the Database" remark= open the current database to ensure that subsequent operations are performed within the current database. ">

<! [cdata[

/* The following statement is very important! */

Use $Parameters [Database]

]]>

</script>

</packet>



<packet name= "SP001" version= "1.1" title= "Patch 1.1" remark= "Patch Notes" >

<script title= "Script" remark= "script Comment -1.1.1" >

<! [cdata[

SELECT * from Master.dbo.sysobjects;

SELECT * from Master.dbo.sysmessages

]]>

</script>

</packet>



<packet name= "SP002" version= "1.2" title= "Patch 1.2" remark= "Patch Notes" >

<script title= Script remark= "script Comment -1.2.1" >

<! [cdata[

SELECT * from Master.dbo.sysobjects

]]>

</script>



<script title= "Script 102" remark= "script Comment -1.2.2" >

<! [cdata[

SELECT * from Master.dbo.sysobjects

]]>

</script>

</packet>

</database>




Installation Information
After the installation is complete, you need to be in the registry of the target computer (in the location of hkey_local_machine\software\<companyname>\<productname><edition> Saves the current installation instance number (the id attribute value of the installation file root) and the database name as well as the script package version, which, when installed at a later time, is based on the saved information to start the installation from the breakpoint.




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.