Why ImportRow is causing NullReferenceException & Rows(0) <> NULL

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

I am receiving a System.NullReferenceException error when the ImportRow is
executed. However, as you can see there are rows in the table and I can see
the data in Rows(0) in the
dsetTempPlaceInfoFromPt.Tables("Places").Item.ItemArray of QuickWatch. Thus
it is not null. The dSetPlaces (where I am trying to copy the row to) does
not have any tables or rows; is that the problem? Does the ImportRow
automatically create the table "Places" in the dataset dSetPlaces if it is
not there? Maybe that's my problem.

If dsetTempPlaceInfoFromPt.Tables("Places").Rows.Count = 1 Then

dSetPlaces.Tables("Places").ImportRow(dsetTempPlaceInfoFromPt.Tables("Places").Rows(0))

I am using .NET 2.0 framework and there are values in the ItemArray of the
Rows(0).

Help!
 
Hi,

Yes, as you assume, the problem is that dSetPlaces doesn't contain a table
named "Places". Because ImportRow is a method of the "Places" DataTable,
now the DataTable even doesn't exist, so this method cannot be called.

In this case, you have to create the DataTable your self, and create all
the columns as the schema of the original DataTable.

Kevin Yu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
Back
Top