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. can I use '+=' in a datarow

can I use '+=' in a datarow

Scheduled Pinned Locked Moved Database
helpquestion
4 Posts 3 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.
  • M Offline
    M Offline
    Maverickcool
    wrote on last edited by
    #1

    hi I have datarow which contains an int column I want to increase the value by 1: (int)row[0][0] += 1 // the first column is an int field but when I do this I get an error: "The left-hand side of an assignment must be a variable, property or indexer" is there a way to do this?

    M C 2 Replies Last reply
    0
    • M Maverickcool

      hi I have datarow which contains an int column I want to increase the value by 1: (int)row[0][0] += 1 // the first column is an int field but when I do this I get an error: "The left-hand side of an assignment must be a variable, property or indexer" is there a way to do this?

      M Offline
      M Offline
      Mycroft Holmes
      wrote on last edited by
      #2

      What database, what language, are you using the CLR. If you are using SQL then you need to learn the language, it is not C#. Thats why they invented linq - to get you poor sods a language you knew.

      Never underestimate the power of human stupidity RAH

      1 Reply Last reply
      0
      • M Maverickcool

        hi I have datarow which contains an int column I want to increase the value by 1: (int)row[0][0] += 1 // the first column is an int field but when I do this I get an error: "The left-hand side of an assignment must be a variable, property or indexer" is there a way to do this?

        C Offline
        C Offline
        Colin Angus Mackay
        wrote on last edited by
        #3

        Maverickcool wrote:

        but when I do this I get an error: "The left-hand side of an assignment must be a variable, property or indexer"

        Don't you want to understand why you get this error? You have cast the left side to an int meaning the left side is no longer the indexer. You could probably write row[0][0] = ((int)row[0][0]) + 1; But, since I don't use DataSets it may or may not work.

        *Developer Day Scotland - Free community conference Delegate Registration Open

        M 1 Reply Last reply
        0
        • C Colin Angus Mackay

          Maverickcool wrote:

          but when I do this I get an error: "The left-hand side of an assignment must be a variable, property or indexer"

          Don't you want to understand why you get this error? You have cast the left side to an int meaning the left side is no longer the indexer. You could probably write row[0][0] = ((int)row[0][0]) + 1; But, since I don't use DataSets it may or may not work.

          *Developer Day Scotland - Free community conference Delegate Registration Open

          M Offline
          M Offline
          Maverickcool
          wrote on last edited by
          #4

          Thanks Colin !

          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