What's wrong with this filter?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello:

I have the following code:

Dim lsFilter As String = Nothing
Select Case rblStatus.SelectedItem.Value
Case "S"
lsFilter = String.Concat("D_STAT_CD_C = '", "N'")
Case "R"
lsFilter = String.Concat("D_STAT_CD_C <> '", "N'")
End Select
If Not lsFilter = Nothing Then
dsMain.Tables(0).Select(lsFilter)
End If

When the value is 'R', it picks up the right filter expression, "D_STAT_CD_C
<> '", "N'", but the Rowcount of dsMain.Tables(0) does not change.

What am I doing wrong?

Venki
 
Hi,

dsMain.Tables(0).Select(lsFilter) will return an array of
datarows. It will not change the count of the datatable.

Ken
 
When the value is 'R', it picks up the right filter expression, "D_STAT_CD_C
<> '", "N'", but the Rowcount of dsMain.Tables(0) does not change.

What am I doing wrong?

Venki

What you're doing wrong is expecting the Rowcount of dsMain.Tables(0) to
change. dsMain.Tables(0).Select(lsFilter) is a method call that will
return a collection of DataRows, and you are just throwing the return value
away.

You probably want to look into the DefaultView property of a DataTable at
this point. It is where you can set a persistent filter and then check the
rowcount.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top