You could also do it with your SQL statement,
I tested this on a table called "groups" and a field called "crop". You will need to use your own table and field names.Code:Using con As New OleDbConnection(My.Settings.waterConnectionString), da As New OleDbDataAdapter("Select crop, count(*) as cnt from groups group by crop", con), dt As New DataTable da.Fill(dt) For Each row As DataRow In dt.Rows Dim str As String = row("crop").ToString & " " & row("cnt").ToString MessageBox.Show(str) Next End Using




Reply With Quote
