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]
-
(E-Mail Removed)
"rodchar" <(E-Mail Removed)> wrote in message
news:6EC4230B-C706-4552-8E7D-(E-Mail Removed)...
> 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