|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
DataView RowFilteringtwo dataviews, one with a list of shows (dvAllShows) and the other with a list of shows attended by a person(dvAttendedShows). I want to walk through all the possible shows, checking if the person attended that show, by seeing if there is a record that contains that ShowID. For Each drAllShows In dvAllShows.Table.Rows filterString = "Show = '" & CStr(drAllShows("ShowID")) & "'" dvAttendedShows.RowFilter = filterString If dvAttendedShows.Table.Rows.Count = 1 Then clbAttendeeShows.Items.Add(drAllShows("ShowName"), True) Else clbAttendeeShows.Items.Add(drAllShows("ShowName"), False) End If Next The Show and ShowID columns are integers, but using '' around the value or not produces the same not working solution. Each time the RowFilter line is executed, all the rows in dvAttended stay exposed. Any suggestions? Thanks, Bernie Bernie,
> For Each drAllShows In dvAllShows.Table.Rows This means the same asFor each datarow in the complete datatable from dvAllShows You probably need something as For each drvAllShows as DataRowView in dvAllShows I hope this helps, Cor Cor,
That's not where the problem is. I need all of the rows in the dvAllShows. It's the vbAttended shows which I need to filter each time I process a row in dvAllShows. dvAllShows is completely different data than dvAttendingShows. They come from different tables in the db, but they have a common key. How do I get the filter of dvAttendingShows to work? For Each drAllShows In dvAllShows.Table.Rows filterString = "Show = '" & CStr(drAllShows("ShowID")) & "'" >>>>> dvAttendedShows.RowFilter = filterString If dvAttendedShows.Table.Rows.Count = 1 ThenclbAttendeeShows.Items.Add(drAllShows("ShowName"), True) Else clbAttendeeShows.Items.Add(drAllShows("ShowName"), False) End If Next Bernie Show quoteHide quote "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in news:etvzgkXeGHA.380@TK2MSFTNGP04.phx.gbl: > Bernie, > >> For Each drAllShows In dvAllShows.Table.Rows > This means the same as > For each datarow in the complete datatable from dvAllShows > > You probably need something as > > For each drvAllShows as DataRowView in dvAllShows > > I hope this helps, > > Cor > > > Bernie,
> That's not where the problem is. I need all of the rows in the It are not all the rows in the dvAllShows it are (normally) much more.> dvAllShows. It's the vbAttended shows which I need to filter each time I > process a row in dvAllShows It are all the rows in the datatables which you are using. This code (you use it more) is without sense because the rowfilter does nothing. Cor Show quoteHide quote "Bernie Hunt" <bh***@optonline.net> schreef in bericht news:Xns97C637D3D8B29bhuntoptonlinenet@207.46.248.16... > Cor, > > That's not where the problem is. I need all of the rows in the > dvAllShows. It's the vbAttended shows which I need to filter each time I > process a row in dvAllShows. > > dvAllShows is completely different data than dvAttendingShows. They come > from different tables in the db, but they have a common key. > > How do I get the filter of dvAttendingShows to work? > > For Each drAllShows In dvAllShows.Table.Rows > filterString = "Show = '" & CStr(drAllShows("ShowID")) & "'" >>>>>> dvAttendedShows.RowFilter = filterString > > If dvAttendedShows.Table.Rows.Count = 1 Then > clbAttendeeShows.Items.Add(drAllShows("ShowName"), True) > Else > clbAttendeeShows.Items.Add(drAllShows("ShowName"), False) > End If > Next > > > Bernie > > > > "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in > news:etvzgkXeGHA.380@TK2MSFTNGP04.phx.gbl: > >> Bernie, >> >>> For Each drAllShows In dvAllShows.Table.Rows >> This means the same as >> For each datarow in the complete datatable from dvAllShows >> >> You probably need something as >> >> For each drvAllShows as DataRowView in dvAllShows >> >> I hope this helps, >> >> Cor >> >> >> > Cor,
Maybe I'm not understanding. These two dataviews are attached to two completely different tables. Let me take this out of the context of the loop. I have a dataview. I count the records in the dataview and there are 5. I filter the dataview and then count the records ands still have 5. Why doesn't that filter work? Messagebox.Show(dvAttendedShows.Rows.Count) ' returns 5 filterString = "Show = '" & CStr(drAllShows("ShowID")) & "'" dvAttendedShows.RowFilter = filterString Messagebox.Show(dvAttendedShows.Rows.Count) ' returns 5 This should have decreased the number of rows in the dataview, but it doesn't. Is there something that I'm missing to implement the filter? Or maybe does the Rows.Count property always return all the rows and not just the filtered? Bernie Cor Ligthert [MVP] wrote: Show quoteHide quote > Bernie, > > > That's not where the problem is. I need all of the rows in the > > dvAllShows. It's the vbAttended shows which I need to filter each time I > > process a row in dvAllShows > > It are not all the rows in the dvAllShows it are (normally) much more. > > It are all the rows in the datatables which you are using. > > This code (you use it more) is without sense because the rowfilter does > nothing. > > Cor > Bernie,
I don't have the names of your original tables so I create a sample here. Suppose you have a datatable dtBernie And you create a new dataview of that dim dvBernie as new DataView(dtBernie) Than is dvBernie.Table the same as dtBernie dvBernie.Table is no dataview it is a datatable. And that is in your code, Therefore is probably what you want in my first answer. for each drv as DataRowView in dvBernie Next I hope that this explains it. Cor Show quoteHide quote "Bernie" <bh***@optonline.net> schreef in bericht news:1147877889.880213.67740@38g2000cwa.googlegroups.com... > Cor, > > Maybe I'm not understanding. These two dataviews are attached to two > completely different tables. Let me take this out of the context of the > loop. > > I have a dataview. I count the records in the dataview and there are 5. > I filter the dataview and then count the records ands still have 5. Why > doesn't that filter work? > > Messagebox.Show(dvAttendedShows.Rows.Count) ' returns 5 > filterString = "Show = '" & CStr(drAllShows("ShowID")) & "'" > dvAttendedShows.RowFilter = filterString > Messagebox.Show(dvAttendedShows.Rows.Count) ' returns 5 > > This should have decreased the number of rows in the dataview, but it > doesn't. > > Is there something that I'm missing to implement the filter? Or maybe > does the Rows.Count property always return all the rows and not just > the filtered? > > Bernie > > > Cor Ligthert [MVP] wrote: >> Bernie, >> >> > That's not where the problem is. I need all of the rows in the >> > dvAllShows. It's the vbAttended shows which I need to filter each time >> > I >> > process a row in dvAllShows >> >> It are not all the rows in the dvAllShows it are (normally) much more. >> >> It are all the rows in the datatables which you are using. >> >> This code (you use it more) is without sense because the rowfilter does >> nothing. >> >> Cor >> > Cor and Jens,
Thanks for your help. I found my problem today. My method of testing was fouled. I was using Messagebox.Show(dvAttendedShows.Rows.Count) to see how many rows were in the dataView. When in fact this show how many rows are in the total dataView. To see the number of rows in the filtered dataView I should have been using Messagebox.Show(dvAttendedShows.Count) It works much better when you get the syntax right, hahahaha. Thanks again! Bernie
Show quote
Hide quote
"Bernie" <bh***@optonline.net> wrote in message Maybe this is a stupid question, but is the ShowID an integer or string ?news:1147877889.880213.67740@38g2000cwa.googlegroups.com... > Cor, > > Maybe I'm not understanding. These two dataviews are attached to two > completely different tables. Let me take this out of the context of the > loop. > > I have a dataview. I count the records in the dataview and there are 5. > I filter the dataview and then count the records ands still have 5. Why > doesn't that filter work? > > Messagebox.Show(dvAttendedShows.Rows.Count) ' returns 5 > filterString = "Show = '" & CStr(drAllShows("ShowID")) & "'" > dvAttendedShows.RowFilter = filterString > Messagebox.Show(dvAttendedShows.Rows.Count) ' returns 5 > > This should have decreased the number of rows in the dataview, but it > doesn't. > > Is there something that I'm missing to implement the filter? Or maybe > does the Rows.Count property always return all the rows and not just > the filtered? > > Bernie > > > Cor Ligthert [MVP] wrote: >> Bernie, >> >> > That's not where the problem is. I need all of the rows in the >> > dvAllShows. It's the vbAttended shows which I need to filter each time >> > I >> > process a row in dvAllShows >> >> It are not all the rows in the dvAllShows it are (normally) much more. >> >> It are all the rows in the datatables which you are using. >> >> This code (you use it more) is without sense because the rowfilter does >> nothing. >> >> Cor >> > In case it is an integer, try with this one: filterString = "Show = " & drAllShows("ShowID") Jens
Byte to Chr - not correctly translated!!
GetDefaultPrinter Saving a JPG from the web to local disk User Software Settings and System Software Settings in Windows Regsitry .NET Remoting Confusion over namespaces CSV file reading every other record... String Name to a User Control? locate a desired row Basic "Help" Question |
|||||||||||||||||||||||