You can do that automatically,
you always need to count records on the DataSet itself
---------------------------------------
Sub BindSQL()
Dim MyConnection As SqlConnection
Dim DS as DataSet
Dim MyCommand As SqlDataAdapter
Dim RcdCount As Integer
'Our SQL string
Dim sqlStr As String = "SELECT titles.title, authors.au_lname, " & _
"authors.au_fname, titles.price " & _
"FROM authors INNER JOIN titleauthor ON " & _
"authors.au_id = titleauthor.au_id " & _
"INNER JOIN titles ON " & _
"titleauthor.title_id = titles.title_id"
'The connection to our database
Dim strConn As String = "server=(local);uid=sa;pwd=;" & _
"database=pubs;Trusted_Connection=yes;"
'Open up our connection with our connection object
MyConnection = New SQLConnection(strConn)
'To execute our Sql Statement and provide our active connection
MyCommand = NewSqlDataAdapter(sqlStr, MyConnection)
'Create instance of DataSet object and fill our predetermined
'datagrid with it and we name it
DS = new DataSet()
MyCommand.Fill(DS, "pubs")
RcdCount = DS.Tables("pubs").Rows.Count.ToString()
RecordCount.Text = "<b><font color=red>" & RcdCount & "</fontrecords
found"
Pubs.DataSource = DS
Pubs.Databind()
lblPageCount.Text = "Page " & Pubs.CurrentPageIndex + 1 & " of " &
Pubs.PageCount
End Sub
---------------------------------------
you can see this link to have a better idea
http://www.developerfusion.co.uk/show/4060/2/
--
Bruno Alexandre
"a Portuguese in København, Danmark"