aDEFWEBSERVER
Los Angeles, CA *  Webmaster@ADefWebserver.com

Creating a Super-Fast and Super-Easy DotNetNuke® Module
For absolute beginners! (For DotNetNuke Version 4.3) - Page 4 (Page 3)

Complete The Code

The steps that remain are:

 
 
   
   
In the previous step you will have opened your DotNetNuke website in the web browser at this point.  
Click LOGIN
Log in as "host". The password (if you haven't already changed it) is also "host"

Create the tables and stored procedures

Click on the HOST menu and select SQL

Paste the following script in the box:

 

 

/** Create Table **/

CREATE TABLE {databaseOwner}[{objectQualifier}ThingsForSale] (
[ID] [int]
IDENTITY(1,1) NOT NULL,
[ModuleId] [int]
NOT NULL,
[UserID] [int]
NULL,
[Category] [nvarchar](25),
[Description] [nvarchar](500),
[Price] [float]
NULL
)
ON [PRIMARY]

ALTER TABLE {databaseOwner}[{objectQualifier}ThingsForSale] ADD
CONSTRAINT
[PK_{objectQualifier}ThingsForSale] PRIMARY KEY CLUSTERED
([ID])
ON [PRIMARY]

GO

/** Create Stored Procedures **/

CREATE PROCEDURE {databaseOwner}[{objectQualifier}ThingsForSale_Delete]
@ID
int
AS
DELETE FROM
{objectQualifier}ThingsForSale
WHERE (ID = @ID)
RETURN
GO

CREATE PROCEDURE {databaseOwner}[{objectQualifier}ThingsForSale_Insert]
@ModuleId
int,
@UserID
int,
@Category
nvarchar(25),
@Description
nvarchar(500),
@Price
float
AS
INSERT INTO
{objectQualifier}ThingsForSale
(ModuleId, UserID, Category, Description, Price)

VALUES
(@ModuleId,@UserID,@Category,@Description,@Price)
RETURN
GO

CREATE PROCEDURE {databaseOwner}[{objectQualifier}ThingsForSale_SelectAll]
@ModuleId
int
AS
SELECT
ID, ModuleId, UserID, Category, Description, Price
FROM {objectQualifier}ThingsForSale
WHERE (ModuleId = @ModuleId)
ORDER BY Category
RETURN
GO

CREATE PROCEDURE {databaseOwner}[{objectQualifier}ThingsForSale_Update]
@ID
int,
@ModuleId
int,
@UserID
int,
@Category
nvarchar(25),
@Description
nvarchar(500),
@Price
float
AS
UPDATE
{objectQualifier}ThingsForSale
SET ModuleId = @ModuleId, UserID = @UserID, Category = @Category, Description = @Description, Price = @Price
WHERE (ID = @ID)
RETURN

Select the "Run as Script" box and click "Execute".  
Watch the progress bar in your web browser because when the script has been run the text in the window will shift and then... nothing... Perhaps we will get a "completed" message some day :)

What Did We Just Do?

We ran a SQL script that created the table and the stored procedures.

You will notice that the script is written like:

CREATE TABLE {databaseOwner}[{objectQualifier}ThingsForSale] 

rather than the normal:

CREATE TABLE [dbo][ThingsForSale]

The script commands "{databaseOwner}" and "{objectQualifier}" indicate that they are to be replaced by configuration settings in the web.config file. Normally "{databaseOwner}" is set to ".dbo" and  "{objectQualifier}" is set to nothing (it would not have a setting). However, if alternate settings were indicated in the web.config file, those settings would be inserted into the script.

You must have the "Run as Script" box checked for this replacement to happen.

 

   
   

Register the module in DotNetNuke

While logged into your DotNetNuke site as "host" in the web browser, from the menu bar select "Host". Then select "Module Definitions".

Click the black arrow that is pointing down to make the fly-out menu to appear. On that menu select "Create New Module".
In the Edit Module Definitions menu:
  • Enter "ThingsForSale" for MODULE NAME
  • Enter "ThingsForSale" for FOLDER TITLE
  • Enter "ThingsForSale" for FRIENDLY TITLE
  • Enter "ThingsForSale" for DESCRIPTION
  • Enter "1.0" for VERSION

Then click UPDATE

 

 

Enter "ThingsForSale" for NEW DEFINITION

Then click "Add"

Next, Click "Add Control"
In the Edit Module Control menu:
  • Enter "ThingsForSale" for TITLE
  • Use the drop-down to select "DesktopModule/ThingsForSale/ViewThingsForSale.ascx" for SOURCE
  • Use the drop-down to select "View" for TYPE

Then click UPDATE 

   
In the upper left hand corner of the website, under the PAGE FUNCTIONS menu click ADD.
In the PAGE MANAGEMENT menu under PAGE DETAILS:
  • Enter "ThingsForSale" for PAGE NAME
  • Enter "ThingsForSale" for PAGE TITLE
  • Enter "ThingsForSale" for DESCRIPTION
  • Click the VIEW PAGE box next to ALL USERS

Then click UPDATE

From the MODULE drop-down select "ThingsForSale".
Then click ADD.
   
The module will now appear.
What Did We Just Do?  
We have created a module definition and added the module to a page.  
   

The tutorial is complete.

If you find any errors or omissions please email me at webmaster@adefwebserver.com  
About the Author:  
PatrickSantry.jpg

Michael Washington is a Website developer and an ASP.NET, C#, and Visual Basic programmer. He has extensive knowledge in process improvement, billing systems, and credit card transaction processing. He is a DotNetNuke Core member and has been involved with DotNetNuke for nearly 3 years. He is the author of numerous DotNetNuke modules and tutorials. He is one of the founding members of the Southern California DotNetNuke Users group (http://socaldug.org). He has a son, Zachary and resides in Los Angeles with his wife Valerie.

 
 
I am sorry but due to the volume of email I am unable to provide personal responses. You can obtain help using the DotNetNuke documentation and the DotNetNuke Forums.  
BACK
 
 
DotNetNuke MarketPlace

(C) by Michael Washington - ADefWebserver.com - Webmaster@ADefWebserver.com

DotNetNuke® is a registered trademark of Perpetual Motion Interactive Systems Inc.