Hi, I am using ASP.NET to make a website, for the first time and I am programming with C#.

When using this code:

var query = SQL.Query("SELECT * FROM campaign");

foreach(var key in query){
    <p>@query["name"]</p>
}

I get this error: CS1579: foreach statement cannot operate on variables of type 'object' because 'object' does not contain a public definition for 'GetEnumerator'

Inspect what kind of class/object SQL.Query returns. It must be enumerable to be able to use foreach.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.