select or access element in datatable

Hi, experts

After I use dataadapter to get data from DB, and fill it in to datatable like below

          SqlDataAdapter DA_subject = new SqlDataAdapter(str_subject_info, str_conn_sql);
            DataTable DT_subject = new DataTable();

Can I use SQL statement in Datatable? or how can I assess the element of the datatable. for example assign an element in datatable to a variable.

Could you please give me example code to do it. thanks in advance

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You can access specific cells in datatable using

var value = DT_subject.Rows[a][i];


DT_subject.Rows[i]("id")   -- to access field by name
rmtogetherAuthor Commented:
Hi, cyberkiwi

I use your code do the following, the "col3" is integer type. but it shows an error (error: method name expected)

            for (int i = 0; i < 5; i++)
                int a = DT_subject.Rows[i]("col3");

Sorry, try this. Mixed vb and c# code

    for (int i = 0; i < 5; i++)
                int a = DT_subject.Rows[i]["col3"];

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.