Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. ADO.NET / Update Column in memory

ADO.NET / Update Column in memory

Scheduled Pinned Locked Moved Database
questioncsharpdatabaseperformanceannouncement
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sebastian Br
    wrote on last edited by
    #1

    Okay, I'm new to the whole ADO.NET stuff, so don't punish me to hard if I ask a total bullshit question... First, here's a piece of code (assume, aDataSet is already initialized and the table "aTable" also exists):

        Dim aRow As DataRow
        aDataSet.Tables("aTable").Columns.Add("isParent", System.Type.GetType("System.Boolean"))
        For Each aRow In Me.mDataSet.Tables("aTable").Rows
            aRow.Item("isParent") = True
        Next
    

    What I wanna do: Add the new column "isParent" to "aTable" (okay, I managed this), and initialize it with a standard value (I do this in the for-next-loop). But I thought, there must be a more elegant way to do this, without picking every single cell in a loop. Anyone know a good solution? I don't need to write in a database, 'cause my aDataSet is build on the fly, without database representation.

    N 1 Reply Last reply
    0
    • S Sebastian Br

      Okay, I'm new to the whole ADO.NET stuff, so don't punish me to hard if I ask a total bullshit question... First, here's a piece of code (assume, aDataSet is already initialized and the table "aTable" also exists):

          Dim aRow As DataRow
          aDataSet.Tables("aTable").Columns.Add("isParent", System.Type.GetType("System.Boolean"))
          For Each aRow In Me.mDataSet.Tables("aTable").Rows
              aRow.Item("isParent") = True
          Next
      

      What I wanna do: Add the new column "isParent" to "aTable" (okay, I managed this), and initialize it with a standard value (I do this in the for-next-loop). But I thought, there must be a more elegant way to do this, without picking every single cell in a loop. Anyone know a good solution? I don't need to write in a database, 'cause my aDataSet is build on the fly, without database representation.

      N Offline
      N Offline
      N a v a n e e t h
      wrote on last edited by
      #2

      DataColumn has a DefaultValue property.

      Navaneeth How to use google | Ask smart questions

      S 1 Reply Last reply
      0
      • N N a v a n e e t h

        DataColumn has a DefaultValue property.

        Navaneeth How to use google | Ask smart questions

        S Offline
        S Offline
        Sebastian Br
        wrote on last edited by
        #3

        It works fine, thanks.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups