[DNN module development] how to write the module database installation script

Source: Internet
Author: User
Tags sql server query dnn

Compiling the DotNetNuke (DNN) module-related database installation/uninstallation scripts is an important part of module development. The DNN program automatically installs or uninstalls tables and stored procedures related to the module based on the script related to the module.

The database installation script of the module in DNN is generally named version number. The specific data access Provider name (for example, the corresponding SQLServer installation file can be 01.00.00.SqlDataProvider ). When uploading a new module, the module installer of DNN executes the database script in version order according to the database script list listed in the DNN file. For upgrade and installation, only the database installation script later than the previous version of the module is executed. Therefore, you must remember this when writing the next version of the database installation script: Modify it on the basis of the original version, rather than rewrite it all. For example, if you only add a stored procedure to a module in the next version, the database script of this version only needs to include the code used to create the stored procedure, and you do not need to rewrite all objects. Pay attention to the consistency between the module version and the database script version.

The database Uninstall script of the module in DNN is generally named as Uninstall. The specific data access Provider name (for example, the Uninstall. SqlDataProvider file corresponding to SQLServer can be used ). When deleting a module, DNN deletes the table and stored procedures related to the module based on the content of the file.

The script can be written as follows (the SQL Server database is used as an example ):
1. Create tables and stored procedures in the database.
2. You can use the SQL Server Query analyzer to generate a script for creating or removing tables and stored procedures. 3. Copy the scripts of these objects to a file, and add the {databaseOwner} {objectQualifier} prefix before the table and stored procedure object names; add the {objectQualifier} prefix to the primary/foreign key name, for example, PK {objectQualifier} _ CLinks and FK _ {objectQualifier} CLinks_Modules.
For the meaning and purpose of {databaseOwner} {objectQualifier}, see: http://www.cnblogs.com/csdn/archive/2004/11/30/71118.html
4. Name the files according to the naming rules of the database installation/uninstall script.
5. For more information, see install or Uninstall a script file in the database of an existing module.
6. It seems that a template can also be used to write a stored procedure, but it seems that it is not very useful. If you are interested, you can check it out:
Aspx "> http://dnnjungle.vmasanas.net/Development/Templates/tabid/28/Default.aspx

A noteworthy problem:
The SQL Server database installation/uninstallation script is executed through the ExecuteScript method in the SqlDataProvider class. This method contains the following sentence: "Dim Delimiter As String =" GO "& ControlChars. crLf ", that is, to separate each SQL statement that can be executed in an SQL script using the" GO + carriage return linefeed. Use Split to separate each statement into an array and execute each SQL statement cyclically. In this way, when writing the database installation/uninstall script, you must note that the "GO + carriage return" line break is added to the end of each statement, especially the "carriage return line break" in the last sentence. Otherwise, either the last sentence cannot be executed or an error is reported.

There is another noteworthy problem:
The script file for database installation/uninstallation must be saved in UTF-8 format; otherwise, an error may occur.

Related content:
DNN module hierarchy: html "> http://www.cnblogs.com/esshs/archive/2005/07/27/201190.html
About module File structure: http://www.cnblogs.com/esshs/archive/2005/07/21/197198.html
About DNN file structure: http://www.cnblogs.com/esshs/archive/2005/07/26/200154.html


Related Article

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.