You can create sql parameters that would limit the number of records returned, for example:
Dim con As New SqlConnection(sqlConnectionString)
Try
con.Open()
Dim ss As String = "SELECT * from myTable where id=@id"
Dim com As New SqlCommand(ss, con)
Dim da As New SqlDataAdapter(com)
Dim param As New SqlParameter
param.SqlDbType = SqlDbType.Int
param.ParameterName = "@id"
param.Value = 7200
da.SelectCommand.Parameters.Add(param)
Dim ds As New DataSet
da.Fill(ds, "my_table")
dg.DataSource = ds.Tables(0)
com.ExecuteNonQuery()
Catch ex As Exception
MsgBox(ex.Message)
Finally
con.Close()
End Try
Look here for further info:
https://msdn.microsoft.com/en-us/library/ms254953(v=vs.110).aspx[
^]