. NET platform Web Application Deployment (database installation and automatic configuration)

Source: Internet
Author: User
It is convenient to deploy Web solutions on the. NET platform. We can use Visual Studio. NET 2003 to add a web installation project and add the project's main output and content files in the deployed "File System Editor", which is easy to install. Program .

   However, the installation program created in this way only includes the web page and ASP. install the DLL files compiled by the net program to the IIS Directory of the target machine. This is acceptable for general applications (for example, the ACCESS database can be packaged into the installer together ); if the database is SQL Server, you need to install the database at the time of deployment. The creation of the installation program will be more complicated. You need to customize the installation program class. Execute the SQL script in the installer class and write the connection string to Web. config.

   L Install Database

Microsoft msdn introduced how to create a database when deploying an application. For example:

Http://msdn.microsoft.com/library/default.asp? Url =/library/en-US/vsintro7/html/vxwlk1_throughusingcusTomactiontocreatedatabasEduringinstallation. asp

This method creates an installer class and calls ADO. net in the installer class to execute an SQL statement (the SQL statement is placed in a text file) to create a database.

   However, this method has a problem. If SQL Server2000 is used to generate a script file for all table creation, views, and stored procedures, ADO is used. net to execute this script file, it will be because the script contains many "go" statements and errors. Of course, we can replace "go" with a line break and use ADO. Net to execute SQL statements one by one. Obviously, the efficiency is relatively low.

 

The best way is to call osql to execute the script. (Or create a CMD file for a database project, and the CMD file also calls osql when creating a database ).

 

First, create an ASP. NET web application, http: // localhost/vbnettest, and open the vbnettest project.

Create a deployment project
1. On the "file" menu, point to "add project" and select "new project ".
2. In the "Add new project" dialog box, select "Install and deploy Project" in the "project type" pane, and select "Web Installation Project" in the "template" pane ". In the Name box, type test installer.
3. Click OK to close the dialog box.
4. The project is added to Solution Explorer and opened in the file system editor.
5. In the Properties window, select productname properties and type gcrm.

Add the output of the vbnettest project to the deployment project.
1. In the file system Editor, select the web application folder. On the "operations" menu, point to "add" and select "project output ".
2. In the "add project output group" dialog box, select "vbnettest" from the "project" drop-down list ".
3. Click OK to close the dialog box.
4. Select the "main output" and "Content File" groups from the list, and click "OK ".

Create installer class
1. On the "file" menu, point to "new" and select "project ".
2. In the Create Project dialog box, select Visual Basic Project in the project type pane, and select class library in the template pane ". In the "name" box, type dbcustomaction.
3. Click open to close the dialog box.
4. Select "Add new project" from the "project" menu ".
5. In the "Add new project" dialog box, select "Installer class ". In the "name" box, type dbcustomaction.
6. Click OK to close the dialog box.

Create custom installation dialog box
1. In Solution Explorer, select the test installer project. On the "View" menu, point to "Editor" and select "User Interface ".
2. In the User Interface Editor, select the "Start" node under "installation. On the "operations" menu, select "add dialog box ".
3. In the "add dialog box", select the "License Agreement" dialog box, and click "OK" to close the dialog box.
4. In the "add dialog box" dialog box, select the "text box (a)" dialog box, and click "OK" to close the dialog box.
5. On the "operations" menu, select "Move Up ". Repeat this step until the "text box (a)" dialog box is located on the "Install Folder" node.
6. In the "properties" window, select the bannertext property and type: Install database ..
7. Select the bodytext attribute and type: the installer will install the database on the target machine.
8. Select the edit1label attribute and type: Database Name :.
9. Select the edit1property property and type customtexta1.
10. Select the edit1value attribute and type: gscrm.
11. Select the edit2label attribute and type: Server Name :.
12. Select the edit2property property and type customtexta2.
13. Select the edit2value attribute and type: (local ).
14. Select the edit3label attribute and enter: User name :.
15. Select the edit3value attribute and type SA.
16. Select the edit3property property and type customtexta3.
17. Select the edit4label attribute and type: Password :.

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.