Geeks With Blogs

News My Blog has been MOVED to https://mfreidge.wordpress.com
Michael Freidgeim's OLD Blog My Blog has been MOVED to https://mfreidge.wordpress.com

I am using typed dataset(generated by VS 2005) that I merged to empty dataset (actually to class, derived from dataset).

When I am accessed a particular row and tried to read value of the row field, I've got 

System.ArgumentException: Column <ColumnName> does not belong to table <TableName>. at System.Data.DataRow.CheckColumn(DataColumn column)

After debugging and digging into Designer generated code, I found that the cause is that
the generated typed-safe columns have property Table as null, when it is exspected to be a reference to owner table.

The fix was unexpectedely easy.

For merged tables it is required to call InitVars() method of generated Table class.
The Table
InitVars() looks like the following
internal void InitVars() {
//For each  table column

this.columnRetrieved = base.Columns["Retrieved"];
}
The function InitVars()  is called in Table constructor and Clone, but is not called during Merge.
It as not a bug, but it should be considered when merge typed datasets into untyped one.

 

Posted on Friday, November 10, 2006 12:58 PM .Net Framework | Back to top


Comments on this post: After Merge of Typed Dataset access to row fields causes System.ArgumentException

# re: After Merge of Typed Dataset access to row fields causes System.ArgumentException
Requesting Gravatar...
ds1.Merge(ds2); not working where bothe the dataset having same datasetname, tablename, columnname and rowvalue for each column.

Left by Johirul Islam on Sep 23, 2008 4:33 AM

# re: After Merge of Typed Dataset access to row fields causes System.ArgumentException
Requesting Gravatar...
Thank you!!!! I wish I had found this a week ago!
Left by Jeff R. on Nov 09, 2013 7:29 AM

Your comment:
 (will show your gravatar)


Copyright © Michael Freidgeim | Powered by: GeeksWithBlogs.net