hey all,
this is what i thought would make sense to me but got the infamous "Object
not instantiated" error:
DataTable dt;
dt = mySprocDt;
DataTableCollection dtColl = null;
dtColl.Add(dt);
instead i had to do this to make it work:
DataSet ds = new DataSet( );
DataTableCollection dtColl = null;
DataTable dt = null;
dt = mySprocDt;
ds.Tables.Add(dt);
dtColl = ds.Tables;
can someone please explain why the first one didn't work?
thanks,
rodchar 4 4216
rodchar,
Well, your dtColl variable is null, and you tried to call a method on
it. You have to assign to the variable if you are going to call a method on
it.
Also, the first section of code shouldn't compile, as you should need to
have assigned something to dt in the declaration. I assumed you had
something like:
DataTable dt = null;
Or:
DataTable dt = mySprocDt;
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"rodchar" <ro*****@discussions.microsoft.comwrote in message
news:6E**********************************@microsof t.com...
hey all,
this is what i thought would make sense to me but got the infamous "Object
not instantiated" error:
DataTable dt;
dt = mySprocDt;
DataTableCollection dtColl = null;
dtColl.Add(dt);
instead i had to do this to make it work:
DataSet ds = new DataSet( );
DataTableCollection dtColl = null;
DataTable dt = null;
dt = mySprocDt;
ds.Tables.Add(dt);
dtColl = ds.Tables;
can someone please explain why the first one didn't work?
thanks,
rodchar
i tried:
DataTableCollection dtColl = new DataTableCollection( )
but that didn't work, how would i instantiate it?
"Nicholas Paldino [.NET/C# MVP]" wrote:
rodchar,
Well, your dtColl variable is null, and you tried to call a method on
it. You have to assign to the variable if you are going to call a method on
it.
Also, the first section of code shouldn't compile, as you should need to
have assigned something to dt in the declaration. I assumed you had
something like:
DataTable dt = null;
Or:
DataTable dt = mySprocDt;
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"rodchar" <ro*****@discussions.microsoft.comwrote in message
news:6E**********************************@microsof t.com...
hey all,
this is what i thought would make sense to me but got the infamous "Object
not instantiated" error:
DataTable dt;
dt = mySprocDt;
DataTableCollection dtColl = null;
dtColl.Add(dt);
instead i had to do this to make it work:
DataSet ds = new DataSet( );
DataTableCollection dtColl = null;
DataTable dt = null;
dt = mySprocDt;
ds.Tables.Add(dt);
dtColl = ds.Tables;
can someone please explain why the first one didn't work?
thanks,
rodchar
Well, what are you trying to create this list for? If you just want a
list of DataTable instances, then why not use List<DataTable>? The
DataTableCollection is tied to the DataSet and it's constructor is
internal/private to System.Data, so you won't be able to instantiate it
directly.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"rodchar" <ro*****@discussions.microsoft.comwrote in message
news:D6**********************************@microsof t.com...
>i tried:
DataTableCollection dtColl = new DataTableCollection( )
but that didn't work, how would i instantiate it?
"Nicholas Paldino [.NET/C# MVP]" wrote:
>rodchar,
Well, your dtColl variable is null, and you tried to call a method on it. You have to assign to the variable if you are going to call a method on it.
Also, the first section of code shouldn't compile, as you should need to have assigned something to dt in the declaration. I assumed you had something like:
DataTable dt = null;
Or:
DataTable dt = mySprocDt;
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"rodchar" <ro*****@discussions.microsoft.comwrote in message news:6E**********************************@microso ft.com...
hey all,
this is what i thought would make sense to me but got the infamous
"Object
not instantiated" error:
DataTable dt;
dt = mySprocDt;
DataTableCollection dtColl = null;
dtColl.Add(dt);
instead i had to do this to make it work:
DataSet ds = new DataSet( );
DataTableCollection dtColl = null;
DataTable dt = null;
dt = mySprocDt;
ds.Tables.Add(dt);
dtColl = ds.Tables;
can someone please explain why the first one didn't work?
thanks,
rodchar
Thanks Nicholas this last reply gave me insight. i didn't know that the
DataTableCollection was tied to the DataSet. I also haven't worked with
generics before so I don't know what List<DataTablebut I'll definitely try
to do some reading up it.
thanks again,
rod.
"Nicholas Paldino [.NET/C# MVP]" wrote:
Well, what are you trying to create this list for? If you just want a
list of DataTable instances, then why not use List<DataTable>? The
DataTableCollection is tied to the DataSet and it's constructor is
internal/private to System.Data, so you won't be able to instantiate it
directly.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"rodchar" <ro*****@discussions.microsoft.comwrote in message
news:D6**********************************@microsof t.com...
i tried:
DataTableCollection dtColl = new DataTableCollection( )
but that didn't work, how would i instantiate it?
"Nicholas Paldino [.NET/C# MVP]" wrote:
rodchar,
Well, your dtColl variable is null, and you tried to call a method on
it. You have to assign to the variable if you are going to call a method
on
it.
Also, the first section of code shouldn't compile, as you should need
to
have assigned something to dt in the declaration. I assumed you had
something like:
DataTable dt = null;
Or:
DataTable dt = mySprocDt;
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"rodchar" <ro*****@discussions.microsoft.comwrote in message
news:6E**********************************@microsof t.com...
hey all,
this is what i thought would make sense to me but got the infamous
"Object
not instantiated" error:
DataTable dt;
dt = mySprocDt;
DataTableCollection dtColl = null;
dtColl.Add(dt);
instead i had to do this to make it work:
DataSet ds = new DataSet( );
DataTableCollection dtColl = null;
DataTable dt = null;
dt = mySprocDt;
ds.Tables.Add(dt);
dtColl = ds.Tables;
can someone please explain why the first one didn't work?
thanks,
rodchar
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: sunaina |
last post by:
This is the first program I am writing using PHP and Mysql. I am
creating a game where user thinks of an object and my program
guesses the object while asking series of yes/no questions. All a...
|
by: Chris S. |
last post by:
I'm trying to make a graphical editor and browser for Pickled files. One
aspect I'm not sure about is how to detect multiple references to the
same data.
For instance, say I had the Pickled...
|
by: Tom |
last post by:
I want to open a recordset object on an .asp page. When I open the
recordset I would like to use a stored procedure that expects a parameter to
be passed for the stored procedure. I will then use...
|
by: Mark D. Anderson |
last post by:
About a month ago Richard Cornford did an interesting analysis of a
memory leak
in jscript (internet explorer) when there are "circular" references
between
DOM objects and (real) jscript objects:...
|
by: Luke |
last post by:
Here is my emails to Danny Goodman (but probably he is very busy so he
didn't answered it).
First email(simple): Subject: JavaScript Arrays
"
We all know the array can act like HashMap, but is...
|
by: Tom |
last post by:
I have a problem, to which I have been unable to find a solution for
days now, after checking numerous references (both in books and
online). Perhaps someone here can help. Here's my problem:
...
|
by: yb |
last post by:
Hi,
Is there a standard for the global 'window' object in browsers? For
example, it supports methods such as setInterval and clearInterval, and
several others.
I know that w3c standardized...
|
by: Hamed |
last post by:
Have I posted the message to wrong newsgroup?
Or
Does the question is so much strage?
Would someone please kindly direct me to a true newsgroup or resource?
Best Regards
Hamed
|
by: =?Utf-8?B?cm9kY2hhcg==?= |
last post by:
hey all,
i noticed if i use the missing schema to fill a datatablecollection the
table names are generic (Table, Table1, Table2)
is there anyway to change that? i tried on the sql side to use an...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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,...
|
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...
|
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,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
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,...
| |