Hi all,
I've got a class with a private DataSet member, and a void display()
method.
The display() method is *supposed* to take the DataSet for the class
(instance), new up a predefined for which has a DataGrid, slap the
DataSet onto the DataGrid, and set the form.visible to true.
I'm having trouble with a very early part of the process. The first
line of display() gives a runtime error:
int numRows = this.ClassDataS etMember.Tables["tbl"].Rows.Count;
Primary exception:
"An unhandled exception of type 'System.NullRef erenceException '
occurred in ***.dll"
Inner exception:
"Additional information: Object reference not set to an instance of an
object."
This runtime error occurs when the main code calls the object.display( )
method.
What am I doing wrong? I thought "this" was the way to say "that owns
the line of code currently running" (or something like that).
How do I get my object's display() method to make use of it's own
object's data?
I'm sure I'm confused over something really stupid - thanks for any
suggestions!
cdj 3 1726
Sorry if I duped a post, MS's web-based thingy has been uncooperative lately.
The "this" keyword references the current instance of a type. So for example
if you have a field in class-level scope, in your case, "ClassDataSetMe mber",
you could refer to it as this.ClassDataS etMember to disambiguate it from a
variable of the same name that is in a lower scope.
It seems from your description that you simply have not populated the field
with an instance of a DataSet. Here is a short example:
public class MyClass
{
public DataSet ClassDataSetMem ber;
public MyClass(DataSet myDataSet )
{
this.ClassDataS etMember = myDataSet;
}
}
Hope that helps.
Peter
--
Co-founder, Eggheadcafe.com developer portal: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Peter wrote:
It seems from your description that you simply have not populated the field
with an instance of a DataSet.
hmm. So you're saying it looks like I'm making the right calls, there's
just nothing there to be called upon? lol - I'll look into it, and post
back if I'm convinced there *is* a DataSet to be referred to.
thanks for the reply!
cdj
Peter wrote:
It seems from your description that you simply have not populated the field
with an instance of a DataSet. Here is a short example:
You were right. (blush) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Huskier |
last post by:
Hi all:
I want to pass a class-member function to pthread_create, and my
code is in the following, but I don't know how to pass
myobj.thread_function to pthread_create function.
#include <pthread.h>
class test
{
public:
|
by: Jay Douglas |
last post by:
Hello, I am needing to pass a class object (this) by reference to a method
in a different class. When I do the following code I get the error (Cannot
pass '<this>' as a ref or out argument because it is read-only) .. Is there
any way to make <this> not read-only?
I have simplified the following code. There is a Task class and a Data
Class. I am trying to pass the task class by ref to the data class.
public class Task
{
|
by: tony |
last post by:
Hello!
I just wonder if you out there have any your suggestion about this matter.
I have a class in this class I have an ArrayList.
In one instance method in this class I fill this ArrayList with values that
have been reda from db.
Now is it possible to say something about what is general best for this
method.
|
by: Joel Hedlund |
last post by:
Hi!
The question of type checking/enforcing has bothered me for a while, and
since this newsgroup has a wealth of competence subscribed to it, I
figured this would be a great way of learning from the experts. I feel
there's a tradeoff between clear, easily readdable and extensible code
on one side, and safe code providing early errors and useful tracebacks
on the other. I want both! How do you guys do it? What's the pythonic
way? Are...
|
by: Francois Appert |
last post by:
This post was originally in the C# Corner site, but their server is
down. I'd like to see if this group can answer.
I program in C++ and am learning C#.
The issue is: why should anybody bother in C# with pass-by-reference
using the "ref" keyword or "out" for objects in a method parameter
list, when, after all, it appears in C# that for all intents and
purposes a reference is always being passed, rather than the real
object (with, it...
| |
by: Lilith |
last post by:
I have a form that invokes two other dialog forms for controlling the
configuration of the program. The dialogs are invoked modally. Rather
than pile up a large number of variables in the primary form I created
a class to hold the configuration data, validate it, save it. etc. An
object of this class is in the main form. The data is all private but
I have public accessors for all of it. My need is to make it
availlable to the two...
|
by: =?Utf-8?B?Umljaw==?= |
last post by:
I have seen examples of passing data from FormB to FormA (Parent To Child)
but I need an example of passind data from FormA to FormB. My main form is
FormA; I will enter some data in textboxes and click a button to bring up
FormB which needs to display values entered in FormA.
Thanks in advance.
|
by: =?Utf-8?B?U3dhcHB5?= |
last post by:
Can anyone suggest me to pass more parameters other than two parameter for
events like the following?
Event:
Onbutton_click(object sender, EventArgs e)"
Event handler:
button.Click += new EventHandler(Onbutton_click);
I want to pass more information related that event. & want to use that
|
by: raylopez99 |
last post by:
Keywords: scope resolution, passing classes between parent and child
forms, parameter constructor method, normal constructor, default
constructor, forward reference, sharing classes between forms.
Here is a newbie mistake that I found myself doing (as a newbie), and
that even a master programmer, the guru of this forum, Jon Skeet,
missed! (He knows this I'm sure, but just didn't think this was my
problem; LOL, I am needling him)
If...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |