Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 42732

Syntax For - Each Question

$
0
0
Hello,

I have a question regarding a database query. So every example I found on the Internet was by using the For each syntax, like this:

Dim evensQuery = From num In numbers
Where num Mod 2 = 0
Select num

For Each number In evensQuery
Console.Write(number & " ")
Next

Now my question is. If I have a database and I want to select a single row using the ID column which is primary key, how do I write my code?
Because I have a single result and the For Each function is for multiple results.

Writing the For Each syntax gives me the correct result because it iterates just once as there is only one record with that index. But it just doesn't sit right.

So, is there another way to navigate through my query results piece by piece?

I hope you understand my question.

Thx.

Viewing all articles
Browse latest Browse all 42732

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>