![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi Gang, The latest in a string of messages dealing with Strongly Typed DataSets. I've got a Strongly Typed DataSet 'filled', but I cannot seem to figure out how to traverse it. My typed DataSet is called 'RPDCY_TDataSet'. It has three columns: TAG, SRC_TAG, DST_TAG. The class was generated with xsd.exe from an XML Schema file (scraped from a database table): RPDCY_TDataSet dsData = new RPDCY_TDataSet(); int nRows = daNew.Fill( dsData, "DATA" ); // daNew is an OleDbDataAdapter. nRows = 55 foreach ( DataTable tbl in dsData.Tables ) DiagnosticLog.Debug( tbl.TableName ); // prints RPDCY_T and DATA DiagnosticLog.Debug( "# rows = " + dsData.Tables[ "DATA" ].Rows.Count.ToString() ); // prints 55 rows DiagnosticLog.Debug( "# rows = " + dsData.RPDCY_T.Rows.Count.ToString() ); // prints 0 rows, not expected foreach ( RPDCY_TDataSet.RPDCY_TRow row in dsData.RPDCY_T.Rows ) // doesn't execute anything - no rows DiagnosticLog.Debug( row.TAG.ToString() + " " + row.SRC_TAG.ToString() + " " + row.DST_TAG.ToString() ); So am I doing something wrong when referencing my Rows of my types DataSet class? |
#3
| |||
| |||
|
|
"Corey Wirun" <corey.wirun (AT) nospam (DOT) ca> wrote in message news:7mGxc.1963$cS.1659 (AT) edtnps89 (DOT) .. Hi Gang, The latest in a string of messages dealing with Strongly Typed DataSets. I've got a Strongly Typed DataSet 'filled', but I cannot seem to figure out how to traverse it. My typed DataSet is called 'RPDCY_TDataSet'. It has three columns: TAG, SRC_TAG, DST_TAG. The class was generated with xsd.exe from an XML Schema file (scraped from a database table): RPDCY_TDataSet dsData = new RPDCY_TDataSet(); int nRows = daNew.Fill( dsData, "DATA" ); // daNew is an OleDbDataAdapter. nRows = 55 foreach ( DataTable tbl in dsData.Tables ) DiagnosticLog.Debug( tbl.TableName ); // prints RPDCY_T and DATA DiagnosticLog.Debug( "# rows = " + dsData.Tables[ "DATA" ].Rows.Count.ToString() ); // prints 55 rows DiagnosticLog.Debug( "# rows = " + dsData.RPDCY_T.Rows.Count.ToString() ); // prints 0 rows, not expected foreach ( RPDCY_TDataSet.RPDCY_TRow row in dsData.RPDCY_T.Rows ) // doesn't execute anything - no rows DiagnosticLog.Debug( row.TAG.ToString() + " " + row.SRC_TAG.ToString() + " " + row.DST_TAG.ToString() ); So am I doing something wrong when referencing my Rows of my types DataSet class? You will find that you now have 2 tables in the dataset. Your DataAdapter.Fill created a new table instead of filling the existing one. This is an annoying "feature" of datasets, it's really easy to add a new table using a DataAdapter. For typed datasets you almost never want to do that. use daNew.Fill( dsData, "RPDCY_T" ); or daNew.Fill( dsData, dsData.RPDCY_T.Rows); instead. David |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |