.NET     Console.WriteLine( "All Things .NET" );
.NET Nerd Blog Home
7.01.2002

 

Why my Typed Dataset Wasn't Working

xxxAdapter::Fill( ds, "TABLENAME" ); // need 2nd param !!!

Argh! I thought the IDE was supposed to make using typed datasets so easy! Despite the fact that I was forcing them into a console app, I should have picked up on this earlier.

The key to filling up a typed dataset is the 2nd parameter to xxxAdapter::Fill! If you don't specify a table name, the data from the select command will be put into a new table that the runtime creates -- the data will NOT be in the "type-safe" table that the typed dataset has created for you.

Details: In the typed dataset generated code, there's an InitClass method that calls Tables.Add( tableXXX ). This creates an empty table in the dataset that should eventually get populated with the data. The 2nd parameter to Fill must match the name of the table already created by the typed dataset code. This is usually the name of the table you pointed to when creating the typed dataset. The embedded DataTable derived class in the dataset code passes this argument to the baseclass upon construction.



Comments: Post a Comment

Powered by Blogger