Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesInserting Data into a Database on Module LoadInserting Data into a Database on Module Load
Previous
 
Next
New Post
1/24/2010 1:58 PM
 

Hi,

Ive developed a module that displays information for a user per website basis. I've upgraded the module recently and its main function is to check the database to see if there is any data in the database. If it has got the data for that particular module it loads it in to its corresponding controls.

The problem i am facing is when i first add the module to a tab, there is no data in the database. At this point i want to insert default values. I have some sample code below can you tell me why i receive the critical error message below?

protected void Page_Load(object sender, EventArgs e)
        {
            RemoveModuleController oController = new RemoveModuleController();
            RemoveModuleInfo oInfo = oController.GetAllEntries(this.ModuleId);

            try
            {
                if (Null.IsNull(oInfo))
                {
                    oInfo.ModuleId = this.ModuleId;
                    oInfo.Instructions = "No instructions for this module";
                    oInfo.PortalId = this.PortalId;
                    oInfo.TabId = this.TabId;
                    oInfo.PortalName = this.PortalSettings.PortalName;
                    oInfo.RequestedBy = this.UserInfo.DisplayName;
                    oInfo.RequestedDateTime = DateTime.Now;
                    oInfo.IsHidden = false;

                    oController.InsertNewInstructions(oInfo);

                    ModuleController.SynchronizeModule(this.ModuleId);
                }
            }
            catch (Exception ex)
            {
                Exceptions.ProcessModuleLoadException(this, ex);
            }

        }

the error message i receive is.

Error: MasterModuleStart is currently unavailable.
DotNetNuke.Services.Exceptions.ModuleLoadException: Object reference not set to an instance of an object. --->
System.NullReferenceException: Object reference not set to an instance of an object. at ssm.Modules.RemoveModule.MasterRemoveModule.Page_Load(Object sender, EventArgs e)

can anyone help?

 
New Post
1/24/2010 6:59 PM
 

Since oInfo will be null inside your conditional, it must first be instantiated before setting its properties:

  if (oInfo == null)
                {
                 oInfo = new RemoveModuleInfo();
                 oInfo.ModuleId = this.ModuleId;
 


Bill, WESNet Designs
Team Lead - DotNetNuke Gallery Module Project (Not Actively Being Developed)
Extensions Forge Projects . . .
Current: UserExport, ContentDeJour, ePrayer, DNN NewsTicker, By Invitation
Coming Soon: FRBO-For Rent By Owner
 
New Post
1/26/2010 8:47 AM
 

Thanks Bill,

That worked a treat.

 
Previous
 
Next
HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesInserting Data into a Database on Module LoadInserting Data into a Database on Module Load


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out