|
-
Dec 11th, 2006, 01:36 AM
#1
Thread Starter
Lively Member
[RESOLVED] [2005] How to know if no rows are returned?
I have a Find button on my form that binds to a dataset. How do check when there is no rows returned and inform the user?
Thanks.
VB Code:
Private Sub FindNameToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FindNameToolStripButton.Click
Me.Cursor = Cursors.WaitCursor
Try
Me.MAILTableAdapter.FillByName(Me.DetailsDataSet.MAIL, Me.NameToolStripTextBox.Text)
Catch ex As Exception
MessageBox.Show("Error: " & ex.Message)
End Try
Me.Cursor = Cursors.Default
End Sub
Last edited by rim78; Dec 11th, 2006 at 02:36 AM.
-
Dec 11th, 2006, 01:38 AM
#2
Re: [2005] How to know if no rows are returned?
Fill and the like are functions and they return the number of rows retrieved, which Intellisense would have told you.
VB Code:
Dim rowCount As Integer = Me.MAILTableAdapter.FillByName(Me.DetailsDataSet.MAIL, Me.NameToolStripTextBox.Text)
-
Dec 11th, 2006, 01:46 AM
#3
Lively Member
Re: [2005] How to know if no rows are returned?
VB Code:
If YourDataset.Tables("NameOfTheTable").Rows.Count = 0 Then
MessageBox.Show("No rows")
End If
-
Dec 11th, 2006, 02:07 AM
#4
Re: [2005] How to know if no rows are returned?
 Originally Posted by Shardox
VB Code:
If YourDataset.Tables("NameOfTheTable").Rows.Count = 0 Then
MessageBox.Show("No rows")
End If
What if the DataTable already had some rows in it?
-
Dec 11th, 2006, 02:36 AM
#5
Thread Starter
Lively Member
Re: [2005] How to know if no rows are returned?
Thank you for the fast reply! I used what jmcilhinney suggested, dim rowCount to check no. of rows retrieved.
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
|