Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Can't figure out this error stuff!
Message
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Miscellaneous
Thread ID:
01157151
Message ID:
01157382
Views:
14
Jess,

>I created a project but not based on MM project. The form however was created based on MM Business Form. The problem is when I called class methods just like below it gives me an error:
>
>this.GetDataSet("SELECT * FROM Orders WHERE CustomerID "+sqlSOrders+" @CustomerID",
>                this.CreateParameter("@CustomerID", sqlPOrders));
>
>error message is:
>
>NullReferenceException was unhandled!
>Object reference not set to an instance of an object.
>
>Note: The same object class works in different form without change.

If this is a non-MM .NET project, make sure you instantiate an MM .NET application object so the form and business objects have access to MM .NET service components.

You can do the following:

  1. Copy the App.cs file from C:\Program Files\Mere Mortals .NET Framework 2005\VC#\Templates\Windows Forms Template, copy it to your root project directory and add it to the project

  2. At application startup, instantiate the application object before trying to access any data or display any form. For example:
    public static AppDesktop App;
    
    /// <summary>
    /// Main application entry point
    /// </summary>
    [STAThread]
    public static void Main()
    {
    	// Instantiate the Application Object
    	App = new AppDesktop();
    }


Best Regards,
Kevin McNeish
Eight-Time .NET MVP
VFP and iOS Author, Speaker & Trainer
Oak Leaf Enterprises, Inc.
Chief Architect, MM Framework
http://www.oakleafsd.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform