Results 1 to 2 of 2

Thread: Count

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2004
    Posts
    83

    Count

    Hi:

    im developing a VB.NET web application. i want to creat a count button which will count the total # of records displayed in a datagrid ( the datagrid may be on a number of pages so it should count the total). The code i came up with is as follows:

    Dim sqlCount As String
    Dim reader As OleDb.OleDbDataReader

    Try

    sqlCount = "Select count (code) from area"

    obj.Query = sqlCount
    reader = obj.returnReader

    If (IsDBNull(reader.Item(0))) = True Then
    lblCount.Text = "0 records returned"

    Else
    blCount.Text = reader.Item(0) & " records"
    End If

    Catch exception As Exception
    lblCount.Text = "0"
    lblComment.Text = "No records returned"

    Finally
    reader.Close()

    it doesnt read the "(If (IsDBNull(reader.Item(0))) = True Then" statement. it jumps to the exception. therefore, i think the problem lies between those lines.

    please help.
    Thanks

  2. #2
    Fanatic Member brown monkey's Avatar
    Join Date
    Jun 2004
    Location
    Cebu
    Posts
    552
    MessageBox.Show(CType(DataGrid1.DataSource, DataTable).Rows.Count.ToString)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width