We help IT Professionals succeed at work.

c# foreach dr in datatable

SimonPrice33
SimonPrice33 asked
on
713 Views
Last Modified: 2014-05-01
Hi Experts

I am in a transition period from VB.Net to C# and am stuck on getting data from a data table so that I can build it into a CSV file.

What I have at the moment is

foreach (DataRow dr in dt.Rows );
                    {

                        EmirSB.Append(dr.item(1) + ",");
                        EmirSB.Append(dr.item(2) + ",");
                        EmirSB.Append(dr.item(3) + ",");

                     }

Open in new window


however i am getting an error the name dr does not exist in the current context.

Where should i place this please?

thanks

Simon
Comment
Watch Question

Facets Developer
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
thank you
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.