none
Reading rows from a table - DataRowBuilder ????????? RRS feed

  • Question

  • I'm trying to understand how to read rows from a table - PERSONER - with minimal amount of code.

    I have made a dataset by dragging the table to the dataset designer and then made this code:

    1             DataSet_SourceTableAdapters.PERSONERTableAdapter tblSource   
    2                 = new TestCopyDataFromOneTableToAnother.DataSet_SourceTableAdapters.PERSONERTableAdapter();  
    3             DataSet_Source.PERSONERRow tblRow = new DataSet_Source.PERSONERRow();  
    4             for (int i = 0; i < tblSource.GetData().Count; i++)  
    5             {  
    6                 tblRow = (DataSet_Source.PERSONERRow)tblSource.GetData().Rows[i];  
    7                 MessageBox.Show(tblRow._CPR_NR.ToString()+" / " +tblRow.Fornavn.ToString()+" "+tblRow.Efternavn.ToString());  
    8      
    9             } 
    BUT in line 3 it needs a "DataRowBuilder" - what is a datarowbuilder ?

    Can it be done more simple ?

    Best regards
    KSor, Denmark

    Best regards KSor, Denmark
    Saturday, January 31, 2009 8:17 AM

Answers

  • You need to use the NewRow() method on the table instead of 'new DataRow()'.
    DataSet_Source.PERSONERRow tblRow = PERSONERTable.NewRow();
    This posting is provided "AS IS" with no warranties, and confers no rights. Please remember to mark the replies as answers if they help.
    Thursday, March 19, 2009 8:37 PM
    Moderator

All replies

  • You need to use the NewRow() method on the table instead of 'new DataRow()'.
    DataSet_Source.PERSONERRow tblRow = PERSONERTable.NewRow();
    This posting is provided "AS IS" with no warranties, and confers no rights. Please remember to mark the replies as answers if they help.
    Thursday, March 19, 2009 8:37 PM
    Moderator
  • Another example for further explanation from Mark Ashton idea


    Datatable1 = new DataSet1.DataTable(); 
    DataSet1.Row newRow = Datatable1.NewRow(); 
    newRow.Field1 = 000000;
    Wednesday, July 29, 2009 8:27 PM