Home All Groups Group Topic Archive Search About

DataTable Reading.....

Author
13 Feb 2006 11:52 PM
Pete Smith
What is the syntax to read the data from a DataTable by row # and (column #
or name)?

..Net Framework 1.1 and VB.Net.

I have the below code from documentation



For Each thisTable In  myDataSet.Tables
        ' For each row, print the values of each column.
        Dim myRow As DataRow
        For Each myRow In  thisTable.Rows
            Dim myCol As DataColumn
            For Each myCol In  thisTable.Columns
                Console.WriteLine(myRow(myCol))
            Next myCol
        Next myRow
    Next thisTable

But I wanted read the datatable data by referencing as above specified.



Thank you,

-Pete

Author
14 Feb 2006 12:06 AM
Chris
Pete Smith wrote:
Show quoteHide quote
> What is the syntax to read the data from a DataTable by row # and (column #
> or name)?
>
> .Net Framework 1.1 and VB.Net.
>
> I have the below code from documentation
>
>
>
> For Each thisTable In  myDataSet.Tables
>         ' For each row, print the values of each column.
>         Dim myRow As DataRow
>         For Each myRow In  thisTable.Rows
>             Dim myCol As DataColumn
>             For Each myCol In  thisTable.Columns
>                 Console.WriteLine(myRow(myCol))
>             Next myCol
>         Next myRow
>     Next thisTable
>
> But I wanted read the datatable data by referencing as above specified.
>
>
>
> Thank you,
>
> -Pete
>
>

For Each thisTable In  myDataSet.Tables
' For each row, print the values of each column.
    Dim myRow As DataRow
         For Each myRow In  thisTable.Rows
             Dim myCol As DataColumn
              For ii as integer = 0 to thisTable.Columns -1
                  Console.WriteLine(myRow(ii))
              Next myCol
    Next myRow
Next thisTable
Author
14 Feb 2006 12:11 AM
Chris
Chris wrote:
Show quoteHide quote
> Pete Smith wrote:
>
>> What is the syntax to read the data from a DataTable by row # and
>> (column #
>> or name)?
>>
>> .Net Framework 1.1 and VB.Net.
>>
>> I have the below code from documentation
>>
>>
>>
>> For Each thisTable In  myDataSet.Tables
>>         ' For each row, print the values of each column.
>>         Dim myRow As DataRow
>>         For Each myRow In  thisTable.Rows
>>             Dim myCol As DataColumn
>>             For Each myCol In  thisTable.Columns
>>                 Console.WriteLine(myRow(myCol))
>>             Next myCol
>>         Next myRow
>>     Next thisTable
>>
>> But I wanted read the datatable data by referencing as above specified.
>>
>>
>>
>> Thank you,
>>
>> -Pete
>>
>>
>
> For Each thisTable In  myDataSet.Tables
> ' For each row, print the values of each column.
>     Dim myRow As DataRow
>         For Each myRow In  thisTable.Rows
>             Dim myCol As DataColumn
>              For ii as integer = 0 to thisTable.Columns -1
>                  Console.WriteLine(myRow(ii))
>              Next myCol
>     Next myRow
> Next thisTable


Oh, and your way doesn't work because a MyRow object does not contain a
DataColumn.  Only the datatable contains a column object.

Chris
Author
14 Feb 2006 12:23 AM
Pete Smith
Thank you for the reply. But it did not answer my question fully.
-Pete


Show quoteHide quote
"Chris" <no@spam.com> wrote in message
news:%233mfvsPMGHA.2604@TK2MSFTNGP09.phx.gbl...
> Chris wrote:
> > Pete Smith wrote:
> >
> >> What is the syntax to read the data from a DataTable by row # and
> >> (column #
> >> or name)?
> >>
> >> .Net Framework 1.1 and VB.Net.
> >>
> >> I have the below code from documentation
> >>
> >>
> >>
> >> For Each thisTable In  myDataSet.Tables
> >>         ' For each row, print the values of each column.
> >>         Dim myRow As DataRow
> >>         For Each myRow In  thisTable.Rows
> >>             Dim myCol As DataColumn
> >>             For Each myCol In  thisTable.Columns
> >>                 Console.WriteLine(myRow(myCol))
> >>             Next myCol
> >>         Next myRow
> >>     Next thisTable
> >>
> >> But I wanted read the datatable data by referencing as above specified.
> >>
> >>
> >>
> >> Thank you,
> >>
> >> -Pete
> >>
> >>
> >
> > For Each thisTable In  myDataSet.Tables
> > ' For each row, print the values of each column.
> >     Dim myRow As DataRow
> >         For Each myRow In  thisTable.Rows
> >             Dim myCol As DataColumn
> >              For ii as integer = 0 to thisTable.Columns -1
> >                  Console.WriteLine(myRow(ii))
> >              Next myCol
> >     Next myRow
> > Next thisTable
>
>
> Oh, and your way doesn't work because a MyRow object does not contain a
> DataColumn.  Only the datatable contains a column object.
>
> Chris
Author
14 Feb 2006 1:21 AM
Chris
Pete Smith wrote:
Show quoteHide quote
> Thank you for the reply. But it did not answer my question fully.
> -Pete
>
>
> "Chris" <no@spam.com> wrote in message
> news:%233mfvsPMGHA.2604@TK2MSFTNGP09.phx.gbl...
>
>>Chris wrote:
>>
>>>Pete Smith wrote:
>>>
>>>
>>>>What is the syntax to read the data from a DataTable by row # and
>>>>(column #
>>>>or name)?
>>>>
>>>>.Net Framework 1.1 and VB.Net.
>>>>
>>>>I have the below code from documentation
>>>>
>>>>
>>>>
>>>>For Each thisTable In  myDataSet.Tables
>>>>        ' For each row, print the values of each column.
>>>>        Dim myRow As DataRow
>>>>        For Each myRow In  thisTable.Rows
>>>>            Dim myCol As DataColumn
>>>>            For Each myCol In  thisTable.Columns
>>>>                Console.WriteLine(myRow(myCol))
>>>>            Next myCol
>>>>        Next myRow
>>>>    Next thisTable
>>>>
>>>>But I wanted read the datatable data by referencing as above specified.
>>>>
>>>>
>>>>
>>>>Thank you,
>>>>
>>>>-Pete
>>>>
>>>>
>>>
>>>For Each thisTable In  myDataSet.Tables
>>>' For each row, print the values of each column.
>>>    Dim myRow As DataRow
>>>        For Each myRow In  thisTable.Rows
>>>            Dim myCol As DataColumn
>>>             For ii as integer = 0 to thisTable.Columns -1
>>>                 Console.WriteLine(myRow(ii))
>>>             Next myCol
>>>    Next myRow
>>>Next thisTable
>>
>>
>>Oh, and your way doesn't work because a MyRow object does not contain a
>>DataColumn.  Only the datatable contains a column object.
>>
>>Chris
>
>
>
What wasn't answered?
Author
14 Feb 2006 1:30 AM
Pete Smith
Is there anyway I can read cell(x,y) in the DataTable?
Thank you,
-Pete

Show quoteHide quote
"Chris" <no@spam.com> wrote in message
news:e9JlxTQMGHA.3732@TK2MSFTNGP10.phx.gbl...
> Pete Smith wrote:
> > Thank you for the reply. But it did not answer my question fully.
> > -Pete
> >
> >
> > "Chris" <no@spam.com> wrote in message
> > news:%233mfvsPMGHA.2604@TK2MSFTNGP09.phx.gbl...
> >
> >>Chris wrote:
> >>
> >>>Pete Smith wrote:
> >>>
> >>>
> >>>>What is the syntax to read the data from a DataTable by row # and
> >>>>(column #
> >>>>or name)?
> >>>>
> >>>>.Net Framework 1.1 and VB.Net.
> >>>>
> >>>>I have the below code from documentation
> >>>>
> >>>>
> >>>>
> >>>>For Each thisTable In  myDataSet.Tables
> >>>>        ' For each row, print the values of each column.
> >>>>        Dim myRow As DataRow
> >>>>        For Each myRow In  thisTable.Rows
> >>>>            Dim myCol As DataColumn
> >>>>            For Each myCol In  thisTable.Columns
> >>>>                Console.WriteLine(myRow(myCol))
> >>>>            Next myCol
> >>>>        Next myRow
> >>>>    Next thisTable
> >>>>
> >>>>But I wanted read the datatable data by referencing as above
specified.
> >>>>
> >>>>
> >>>>
> >>>>Thank you,
> >>>>
> >>>>-Pete
> >>>>
> >>>>
> >>>
> >>>For Each thisTable In  myDataSet.Tables
> >>>' For each row, print the values of each column.
> >>>    Dim myRow As DataRow
> >>>        For Each myRow In  thisTable.Rows
> >>>            Dim myCol As DataColumn
> >>>             For ii as integer = 0 to thisTable.Columns -1
> >>>                 Console.WriteLine(myRow(ii))
> >>>             Next myCol
> >>>    Next myRow
> >>>Next thisTable
> >>
> >>
> >>Oh, and your way doesn't work because a MyRow object does not contain a
> >>DataColumn.  Only the datatable contains a column object.
> >>
> >>Chris
> >
> >
> >
> What wasn't answered?
Author
14 Feb 2006 1:42 AM
Chris
Pete Smith wrote:
Show quoteHide quote
> Is there anyway I can read cell(x,y) in the DataTable?
> Thank you,
> -Pete
>
> "Chris" <no@spam.com> wrote in message
> news:e9JlxTQMGHA.3732@TK2MSFTNGP10.phx.gbl...
>
>>Pete Smith wrote:
>>
>>>Thank you for the reply. But it did not answer my question fully.
>>>-Pete
>>>
>>>
>>>"Chris" <no@spam.com> wrote in message
>>>news:%233mfvsPMGHA.2604@TK2MSFTNGP09.phx.gbl...
>>>
>>>
>>>>Chris wrote:
>>>>
>>>>
>>>>>Pete Smith wrote:
>>>>>
>>>>>
>>>>>
>>>>>>What is the syntax to read the data from a DataTable by row # and
>>>>>>(column #
>>>>>>or name)?
>>>>>>
>>>>>>.Net Framework 1.1 and VB.Net.
>>>>>>
>>>>>>I have the below code from documentation
>>>>>>
>>>>>>
>>>>>>
>>>>>>For Each thisTable In  myDataSet.Tables
>>>>>>       ' For each row, print the values of each column.
>>>>>>       Dim myRow As DataRow
>>>>>>       For Each myRow In  thisTable.Rows
>>>>>>           Dim myCol As DataColumn
>>>>>>           For Each myCol In  thisTable.Columns
>>>>>>               Console.WriteLine(myRow(myCol))
>>>>>>           Next myCol
>>>>>>       Next myRow
>>>>>>   Next thisTable
>>>>>>
>>>>>>But I wanted read the datatable data by referencing as above
>
> specified.
>
>>>>>>
>>>>>>
>>>>>>Thank you,
>>>>>>
>>>>>>-Pete
>>>>>>
>>>>>>
>>>>>
>>>>>For Each thisTable In  myDataSet.Tables
>>>>>' For each row, print the values of each column.
>>>>>   Dim myRow As DataRow
>>>>>       For Each myRow In  thisTable.Rows
>>>>>           Dim myCol As DataColumn
>>>>>            For ii as integer = 0 to thisTable.Columns -1
>>>>>                Console.WriteLine(myRow(ii))
>>>>>            Next myCol
>>>>>   Next myRow
>>>>>Next thisTable
>>>>
>>>>
>>>>Oh, and your way doesn't work because a MyRow object does not contain a
>>>>DataColumn.  Only the datatable contains a column object.
>>>>
>>>>Chris
>>>
>>>
>>>
>>What wasn't answered?
>
>
>

My example just showed you how to read every cell in the datatable.

To be more exact:
myDataSet.Tables(Z).Rows(Y).Item(X)

Chris
Author
14 Feb 2006 2:49 AM
Pete Smith
Thank you,
-Pete

Show quoteHide quote
"Chris" <no@spam.com> wrote in message
news:u$r3ffQMGHA.2528@TK2MSFTNGP12.phx.gbl...
> Pete Smith wrote:
> > Is there anyway I can read cell(x,y) in the DataTable?
> > Thank you,
> > -Pete
> >
> > "Chris" <no@spam.com> wrote in message
> > news:e9JlxTQMGHA.3732@TK2MSFTNGP10.phx.gbl...
> >
> >>Pete Smith wrote:
> >>
> >>>Thank you for the reply. But it did not answer my question fully.
> >>>-Pete
> >>>
> >>>
> >>>"Chris" <no@spam.com> wrote in message
> >>>news:%233mfvsPMGHA.2604@TK2MSFTNGP09.phx.gbl...
> >>>
> >>>
> >>>>Chris wrote:
> >>>>
> >>>>
> >>>>>Pete Smith wrote:
> >>>>>
> >>>>>
> >>>>>
> >>>>>>What is the syntax to read the data from a DataTable by row # and
> >>>>>>(column #
> >>>>>>or name)?
> >>>>>>
> >>>>>>.Net Framework 1.1 and VB.Net.
> >>>>>>
> >>>>>>I have the below code from documentation
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>For Each thisTable In  myDataSet.Tables
> >>>>>>       ' For each row, print the values of each column.
> >>>>>>       Dim myRow As DataRow
> >>>>>>       For Each myRow In  thisTable.Rows
> >>>>>>           Dim myCol As DataColumn
> >>>>>>           For Each myCol In  thisTable.Columns
> >>>>>>               Console.WriteLine(myRow(myCol))
> >>>>>>           Next myCol
> >>>>>>       Next myRow
> >>>>>>   Next thisTable
> >>>>>>
> >>>>>>But I wanted read the datatable data by referencing as above
> >
> > specified.
> >
> >>>>>>
> >>>>>>
> >>>>>>Thank you,
> >>>>>>
> >>>>>>-Pete
> >>>>>>
> >>>>>>
> >>>>>
> >>>>>For Each thisTable In  myDataSet.Tables
> >>>>>' For each row, print the values of each column.
> >>>>>   Dim myRow As DataRow
> >>>>>       For Each myRow In  thisTable.Rows
> >>>>>           Dim myCol As DataColumn
> >>>>>            For ii as integer = 0 to thisTable.Columns -1
> >>>>>                Console.WriteLine(myRow(ii))
> >>>>>            Next myCol
> >>>>>   Next myRow
> >>>>>Next thisTable
> >>>>
> >>>>
> >>>>Oh, and your way doesn't work because a MyRow object does not contain
a
> >>>>DataColumn.  Only the datatable contains a column object.
> >>>>
> >>>>Chris
> >>>
> >>>
> >>>
> >>What wasn't answered?
> >
> >
> >
>
> My example just showed you how to read every cell in the datatable.
>
> To be more exact:
> myDataSet.Tables(Z).Rows(Y).Item(X)
>
> Chris