am developing software using sql database. i want an sql statement that can enable me retrieve data which for example has same surname,save them in an array or dataset and navigate through them.

am developing software using sql database. i want an sql statement that can enable me retrieve data which for example has same surname,save them in an array or dataset and navigate through them.

Private ds As DataSet = Nothing

Private Function CollectData() As Boolean
   Dim con As New SqlConnection("connectionstring")
   Dim da As SqlDataAdapter = Nothing
   ds = New DataSet()
   
   Try
      con.Open()
      da = New SqlDataAdapter("SELECT * FROM table", con)
      da.Fill(ds)
      con.Close()
   Catch ex As Exception
      Return False
   End Try
   Return True
End Function

Private Function FindRecord(Surname As String) As DataRow()
   Dim row() As DataRow

   Try
      row = ds.Tables(0).Select("surname = '" & Surname & "'")
   Catch ex As Exception
      Return Nothing
   End Try
   Return row
End Function