473,587 Members | 2,263 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dataview rowfilter problem

11 New Member
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.rowfil ter 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 2702
AlexW
11 New Member
Problem solved

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

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

Similar topics

5
15789
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 DataView_Filter = new DataView(); DataView_Filter.Table = DS_States.Tables; sFilter = "Emplcode = '123233'"; DataView_Filter.RowFilter = sFilter;...
3
341
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... DataView dv = new DataView(myTable, "field1 like '" + buffer + "*' and field2 = true", "field1", DataViewRowState.CurrentRows); The above doesn't...
1
2104
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 there any way to get the Dataview to keep track of the different RowFilter used?
2
2292
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 0's using the following code: DataView largeview = new DataView(); largeview.RowFilter = "Large=1"; largeview.Table = adSet1.Tables; DataView...
8
3882
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 = "'Record ID' = '0'"; theView.RowStateFilter = DataViewRowState.ModifiedCurrent; Debug.WriteLine(string.Format("RowFilter = {0}",...
3
1767
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 integer columns I want to use the RowFilter to get the 'records' where one of the integer columns holds a certain integer and use that dataview as...
7
5613
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 with databinding. The data from the 2 detail tables are displayed in 2 datagridviews. I filter each datagridview with a Dataview object using the...
3
2985
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 like this:- Select POSTAL_ADDRESS as "Postal Address" from Emp where .... Now the column name in Dataview is "Postal Address" which is having a...
5
11824
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 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...
0
7915
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7843
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8339
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6619
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5712
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5392
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3872
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1452
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1185
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.