REPOST System.Data.DataTable

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John Smith

    REPOST System.Data.DataTable


    This works:

    Dim dt As System.Data.Dat aTable
    Dim r As System.Data.Dat aRow = dt.Rows.Item(i)
    i = r.Item(2)

    But, I would like to retirive column value by entering
    column name not by index ( r.Item(2)
    ). The problem is that I don't know column name and I would like somehow to
    list all column names of DataTable. How can I do that?

    Please help and sorry for incomplete info.


  • Aidy

    #2
    Re: REPOST System.Data.Dat aTable

    r = dt.Rows(i)
    i = r("FieldName" )

    Not too hot on VB.net, you might need;

    i = r.Item("FieldNa me")

    "John Smith" <john.smith@mic rosoft.comwrote in message
    news:2itzj.6870 $HS3.383783@new s.siol.net...
    >
    This works:
    >
    Dim dt As System.Data.Dat aTable
    Dim r As System.Data.Dat aRow = dt.Rows.Item(i)
    i = r.Item(2)
    >
    But, I would like to retirive column value by entering
    column name not by index ( r.Item(2)
    ). The problem is that I don't know column name and I would like somehow
    to
    list all column names of DataTable. How can I do that?
    >
    Please help and sorry for incomplete info.
    >
    >
    >

    Comment

    • John Smith

      #3
      Re: REPOST System.Data.Dat aTable


      The problem is that I don't know field name. :(


      Comment

      • Aidy

        #4
        Re: REPOST System.Data.Dat aTable


        "John Smith" <john.smith@mic rosoft.comwrote in message
        news:O3uzj.6871 $HS3.383764@new s.siol.net...
        >
        The problem is that I don't know field name. :(
        >
        Sorry, didn't read the question. To get all the column names (sorry it's in
        c#)

        foreach (DataColumn col in dt.Columns)

        {

        string name = col.ColumnName;

        }


        Comment

        • John Smith

          #5
          Re: REPOST System.Data.Dat aTable

          foreach (DataColumn col in dt.Columns)
          >
          {
          >
          string name = col.ColumnName;
          >
          }
          Thank you. I will try that.


          Comment

          Working...