|
-
Sep 28th, 2004, 04:56 AM
#1
Thread Starter
Lively Member
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
-
Sep 28th, 2004, 05:13 AM
#2
Fanatic Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|