Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8009799
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:33:03+00:00 2026-06-04T18:33:03+00:00

I have a question, how to read a specific column form data set…. I

  • 0

I have a question, how to read a specific column form data set….

I have this code:

cmd_line.CommandText = "SELECT IDOC_NUM, SEG_NUM FROM AGR3PL_LINE WHERE IDOC_NUM = '" + Lidoc_num + "'";

OracleDataAdapter ora_adapter_li = new OracleDataAdapter(cmd_line);
DataSet ds_idoc_li = new DataSet("AGR3PL_LINE");
ora_adapter_li.Fill(ds_idoc_li, "AGR3PL_LINE");

if (ds_idoc_li.Tables[0].Rows.Count == 0)
{
   SEG_NUM_L = 1;
}
else
{
   int var = Convert.ToInt32(ds_idoc_li.Tables["AGR3PL_LINE"]["SEG_NUM"]);
   SEG_NUM_L = var;
   SEG_NUM_L++;
}

First I make a select to extract SEG_NUM variable, then I check if is there any row in dataset, if is not set SEG_NUM = 1, else if there is any data extract SEG_NUM, read it and increment it for 1.

I have problem with this part:

int var = Convert.ToInt32(ds_idoc_li.Tables[“AGR3PL_LINE”].Rows[0][“SEG_NUM”]);

If I have 2 entries it works fine, but if there are more than 2 entries I get an error for 3. entry: There is no line at position 0, the counter always increments for 2.

This part is not right

 Convert.ToInt32(ds_idoc_li.Tables["AGR3PL_LINE"].Rows[0]["SEG_NUM"]);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T18:33:04+00:00Added an answer on June 4, 2026 at 6:33 pm

    you can access column value from the Rows collection of the DataTable as:

    Convert.ToInt32(ds_idoc_li.Tables["AGR3PL_LINE"].Rows[indexofRow][columnName or Index]);
    

    Try this:

    if (ds_idoc_li.Tables[0].Rows.Count == 0)
    {
       SEG_NUM_L = 1;
    }
    else
    {
      foreach(DataRow row in ds_idoc_li.Tables["AGR3PL_LINE"].Rows)
      {
       int var = Convert.ToInt32(row["SEG_NUM"]);
       SEG_NUM_L = var;
       }
       SEG_NUM_L++;  
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please read Update1 first! This is SSIS specific question. I have the following tasks:
I have read this question but it's not quite what I was looking for.
First, I have researched this question a lot. I learned how to read from
I have a dataset and my question is how can I read a specific
I have read this question and found its answer to be useful to check
I have question about sending emails from MVC3 application. I already read for exmple
I have a question: I am using fread to read a file. typedef struct
Hello is have a question for a school assignment i need to : Read
I have a question about the C++ visibility attribute. I have read http://gcc.gnu.org/wiki/Visibility and
simple question: I have an file online (txt). How to read it and check

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.