Results 1 to 2 of 2

Thread: reading a datatable

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2001
    Location
    Worcester, MA
    Posts
    77

    reading a datatable

    So I create a datatable like so:
    Code:
    Dim objDT As System.Data.DataTable = New System.Data.DataTable("psearch")
            objDT.Columns.Add("ID", GetType(Integer))
            objDT.Columns("ID").AutoIncrement = True
            objDT.Columns("ID").AutoIncrementSeed = 1
            objDT.Columns.Add("Item", GetType(String))
            objDT.Columns.Add("Criteria", GetType(String))
            objDT.Columns.Add("sys_name", GetType(String))
            objDT.Columns.Add("condition", GetType(String))
            Session("psearch") = objDT

    And then I add some things in like so:
    Code:
    Dim objdt As System.Data.DataTable
    Dim objdr As System.Data.DataRow
    objdt = Session("psearch")
    objdr = objdt.NewRow
    objdr("Item") = trim(actual)
                    objdr("Criteria") = Request(name)
                    objdr("sys_name") = name
                    objdr("condition") = condition
                    objdt.Rows.Add(objdr)
                    Session("psearch") = objdt

    Now how can I read thru it after I am done with it? I wanna loop thru each row to add values to a database.
    "Find all you need in your mind if you take the time" -DT

  2. #2
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    VB Code:
    1. Dim dr As DataRow
    2.  
    3. For Each dr In myDatatable.Rows
    4.      dr("fieldname") = " "
    5. Next
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width