C # Foreach Datarow problem

Discussion in 'Software' started by cpaine, Jun 17, 2009.

  1. cpaine

    cpaine

    Joined:
    Jun 17, 2009
    Messages:
    1
    I am trying to assign column values from my dataset to variables, so that I can use them later. They need to be data type = int (not string), so I can use them later as hex payload.

    Here is the code in question:

    foreach (DataRow row in serial.Rows)
    Console.WriteLine(((int)row["planeId"]).ToString());
    pl = (((int)row["planeId"]).ToString());

    "serial" is my dataset. The code works fine up until the last line, and I get the compile error- "The name "row" does not exist in the current context".

    I'm sure I'm doing something dumb, but do not understand why I can use my "row" name and write to the console, but cannot use it to assign the value to a variable.

    Any suggestions would be appreciated!!!

    Thanks-

    colleen
     
    cpaine, Jun 17, 2009
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tom Accuosti
    Replies:
    3
    Views:
    559
    Travis Evans
    Sep 27, 2004
  2. Vic

    Setup MSN Shorcut problem and IE problem

    Vic, May 11, 2004, in forum: Computer Support
    Replies:
    1
    Views:
    763
    °Mike°
    May 11, 2004
  3. Happy@Camper.Com
    Replies:
    4
    Views:
    12,545
    Happy@Camper.Com
    Jan 18, 2005
  4. Robert11
    Replies:
    2
    Views:
    1,560
    sherlockolms
    Apr 6, 2007
  5. Adrian Przestroga
    Replies:
    1
    Views:
    838
    alexd
    Dec 12, 2010
Loading...

Share This Page