473,395 Members | 1,885 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Dataview rowfilter problem

11
Hi

I am in the process of developing an inventory application in visual basic. I keep coming up against a problem with using the dataview.rowfilter property.
Basically what happens is this:

-a global dataview is created
-The user enters new part information into a form.
-A function is called to check to see if the part is a new part (so that two identical part numbers are not added to the database.
-The check is done by setting the rowfilter value to the string representation of the partnumber and checking if the dataview's .count method returns 0 (ie the rowfilter that was applied hides everything)
-if the function returns true then the .addnew() method of the dataview is invoked and the part details are added to the dataview. (the updating of the actual database will be done later through a user dialog)

The above works perfectly for the first part number but not for any parts added after this. The reason is that for some reason the rowfilter that is applied does not filter out the newly added part, even though the row filter should have filtered this part out because the part Numbers are completely different.
I have checked that the values are being correctly set by stepping through the function line by line and have also made sure that no other functions are being called during its execution.

Any Ideas?

Here is the code of the function below:

Expand|Select|Wrap|Line Numbers
  1. Private Function checkPartIsNew(ByVal partNumber As String) As Boolean
  2.         Dim filterString As String
  3.  
  4.         'variables used for debugging purposes only
  5.         Dim test As DataRowView 'for testing
  6.         Dim testpartNum As String 'for testing
  7.         Dim messageString As String 'for testing
  8.  
  9.         'checking to see if a row filter already exists
  10.         addPartsDataView.RowStateFilter = DataViewRowState.OriginalRows
  11.         If IsNothing(addPartsDataView.RowFilter) = False Then
  12.  
  13.             messageString = "rowFilterApplied, "
  14.  
  15.             'there must already be a rowfilter applied, take steps to preserve it
  16.             filterString = addPartsDataView.RowFilter
  17.             addPartsDataView.RowFilter = Nothing 'put in during debugging to ensure row filter is removed
  18.  
  19.             'set row filter to partNumber
  20.             addPartsDataView.RowFilter = "partNum = '" + partNumber + "'"
  21.  
  22.             'test if part is new/unique
  23.             If addPartsDataView.Count = 0 Then
  24.                 'part must be unique (filter returns no rows)
  25.                 'reapply filter
  26.                 addPartsDataView.RowFilter = filterString
  27.                 Return True
  28.             End If
  29.  
  30.             messageString = messageString + "Addpartsdataview.count equals " + addPartsDataView.Count.ToString + ", "
  31.  
  32.         Else
  33.             'no row filter is currently applied
  34.             messageString = "No row filter applied, "
  35.             addPartsDataView.RowFilter = Nothing
  36.  
  37.             'set row filter to partNumber
  38.             addPartsDataView.RowFilter = "partNum = '" + partNumber + "'"
  39.  
  40.             'test if part is new/unique
  41.             If addPartsDataView.Count = 0 Then
  42.             'part must be unique (filter returns no rows)
  43.                 'remove filter
  44.                 addPartsDataView.RowFilter = Nothing
  45.                 Return True
  46.             End If
  47.  
  48.             messageString = messageString + "Addpartsdataview.count equals " + addPartsDataView.Count.ToString + ", "
  49.  
  50.         End If
  51.  
  52.         'for debugging only
  53.         test = addPartsDataView(0)
  54.         testpartNum = test.Item("PartNum")
  55.         MsgBox(messageString)
  56.  
  57.         'if we are here then part already exists
  58.         Return False
  59.     End Function 
Any Help Would be most appreciated.

Thanks in advance
Oct 19 '07 #1
1 2677
AlexW
11
Problem solved

http://www.thescripts.com/forum/showthread.php?p=2893824#post2893824
Oct 22 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Jim Heimer | last post by:
When I use the dataview.rowfilter and I try to display the field value of the first row, the code doesn't seem to show the first row AFTER the rowfilter. This is my code: DataView...
3
by: Randy | last post by:
Hello All, I'm trying to use a DataView and in the rowfilter, base it on two fields in the table. I can't find any examples on this. Is there a way to do it. I'm talking about something like......
1
by: Webgour | last post by:
I'm tring to filter a dataview with multiple rowfilters. The problem is that each time I use RowFilter on the DataView i'm quering the full dataview as it was loaded, not the filtered version. Is...
2
by: Ryan Moore | last post by:
I have a dataset (called adset) which has a column called "Large" which is either an integer 0 or 1. I am creating 2 dataviews, one which should display the 1's and one which should display the...
8
by: Dave Hagerich | last post by:
I'm using a DataGrid with a DataSet and I'm trying to filter the data being displayed, using the following code as a test: DataView theView = new DataView(theDataSet.Tables); theView.RowFilter =...
3
by: Catullus | last post by:
Hi everyone, I'm a n00b on VB.net programming and now I stumbled upon a problem I can't solve, even after browsing the net for hours.. I have a dataview witg 4 columns; 2 string columns and 2...
7
by: Rich | last post by:
Hello, I am pulling master data from one master table and detail data from two detail tables. The rows from the master data are displayed in textboxes on my form which are bound to the data...
3
by: Anup Daware | last post by:
Abstract: I want to filter a dataview with a value where column name have a SPACE. Description:- I bind a dataview to a datagrid, The query which is fetching the results in Dataset is something...
5
by: AlexW | last post by:
Hi I am in the process of developing an inventory application in visual basic. I keep coming up against a problem with using the dataview.rowfilter property. Basically what happens is this: -a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.