Question Count rows on dataset with WHERE condition

ObiJuan

New member
Joined
Jan 7, 2010
Messages
2
Programming Experience
1-3
Hello,

I have a dataset that I search using the

dataset.tables("table").Select("WHERE clause")

method to query. I then use a datarepeater to display the results.
Is there a way to programatically tell if no results are returned?

I'm aware of the Dataset.tables.Rows.count, but can this be done after the select method?

VB.NET:
        Dim intRowCount As Integer


FrmReport.DataRepeater1.DataSource() = DataSet.Tables("tblWO").Select(strCriteria)

intRowCount = FrmReport.DataRepeater1.DataSource.tables("tblWO").rows.count

if introwcount = 0 then
  msgbox("no rows")
end if

Thanks in advance for your help
 
Solution

I'm not sure if it's possible to do what I asked, but I found a way to do what I need.

after setting the datasource to the datarepeater, the datarepeater has an itemcount property that returns an integer.

VB.NET:
        Dim intRowCount As Integer
        FrmReport.DataRepeater1.DataSource() = DataSet.Tables("tblWO").Select(strCriteria)
        intRowCount = FrmReport.DataRepeater1.ItemCount

        If intRowCount = 0 Then
            MsgBox("No records found, Please try your search again")
            Exit Sub
        End If

-Omar
 
I am using this method due to not being able to find a means to use a Count(*):

VB.NET:
If Dataset.Tables(0).Select("SomeColumn = SomeCriteria").Length > 0 then
    MessageBox.Show("Records Exist")
End If
 

Latest posts

Back
Top