Avatar of SimonPrice33
SimonPrice33
 asked on

c# foreach dr in datatable

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
C#.NET ProgrammingASP.NET

Avatar of undefined
Last Comment
SimonPrice33

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Ganapathi

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SimonPrice33

ASKER
thank you
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy