Knight Data Access Layer
Search Count VB.NET
Basic Tasks VB.NET > Loading Data > Search Count VB.NET

The SearchCount method is useful when needing to know how many total records there are for a search.  This is important when paging is performed.

 

'Create a new Person to save to the database

Dim currentPerson As New Person()

currentPerson.FirstName = "John"

currentPerson.LastName = "Smith"

 

'Get the current instance of the helper

Dim db As IDataHelper = DataHelper.SessionFactory()

 

'Save it to the database

db.Save(currentPerson)

 

'Search parameters

Dim searchParm As New Person()

searchParm.FirstName = "John"

 

'Search for records based on the passed in search object

Dim count As Long= _db.SearchCount(searchParm)