473,386 Members | 1,699 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,386 software developers and data experts.

Regular Expressions in dataview.rowfilter

According to what I see in the manuals I should be able to use regular
expressions with the rowfilter property of a dataview but I keep getting
errors.
Example:
I want to find any rowview where column APCode is not a string of exactly 3
uppercase letters.
Assume dtBAirpt is an instance of a datatable having a column APCode
Code snippet
Try
Dim dvTest As New DataView(dtBAirpt, _
"APCode NOT LIKE '[A-Z][A-Z][A-Z]'", "APCode", _
DataViewRowState.CurrentRows)
If dvTest.Count > 0 Then
For iLoop = 0 To dvTest.Count - 1
oRV = dvTest.Item(iLoop)
sRowInfo = FmtRowInfo(oRV)
AddErrorRow("INVLD STATION", sRowInfo, "ERROR")
oRV.Delete()
Next
End If
Catch ex As Exception
Console.WriteLine("Error: " & ex.Message)
End Try

Console:
Error: Error in Like operator: the string pattern '[A-Z][A-Z][A-Z]' is
invalid.

If I change the string pattern to '???' I can successfully test for 3
characters but that does not address the uppercase.

Anyone know how, or if it is possible to use a regular expression in a
dataview.rowfilter property?

Regards,
Erik
Nov 21 '05 #1
1 9109
Erik,
The DataSet object model supports a very limited regular expression syntax.
To see what expressions are supported look at the DataColumn.Expression
topic.

It appears that the Like operator only supports "*" and "%". I don't see "?"
listed, so I'm really not sure what it is matching. When I try "?" with Like
it has not effect that I can see...

Square brackets "[" and "]" are actually used to escape special characters,
rather then define a set of characters... For example to search for
literally * in a column you would use:

Like '*[*]*'

Hope this helps
Jay

"Engineerik" <En********@discussions.microsoft.com> wrote in message
news:F6**********************************@microsof t.com...
According to what I see in the manuals I should be able to use regular
expressions with the rowfilter property of a dataview but I keep getting
errors.
Example:
I want to find any rowview where column APCode is not a string of exactly
3
uppercase letters.
Assume dtBAirpt is an instance of a datatable having a column APCode
Code snippet
Try
Dim dvTest As New DataView(dtBAirpt, _
"APCode NOT LIKE '[A-Z][A-Z][A-Z]'", "APCode", _
DataViewRowState.CurrentRows)
If dvTest.Count > 0 Then
For iLoop = 0 To dvTest.Count - 1
oRV = dvTest.Item(iLoop)
sRowInfo = FmtRowInfo(oRV)
AddErrorRow("INVLD STATION", sRowInfo, "ERROR")
oRV.Delete()
Next
End If
Catch ex As Exception
Console.WriteLine("Error: " & ex.Message)
End Try

Console:
Error: Error in Like operator: the string pattern '[A-Z][A-Z][A-Z]' is
invalid.

If I change the string pattern to '???' I can successfully test for 3
characters but that does not address the uppercase.

Anyone know how, or if it is possible to use a regular expression in a
dataview.rowfilter property?

Regards,
Erik

Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: vbnetrookie | last post by:
In the dataview rowfilter property, how can I say that I just want Titles that start with 'A' to 'J' ?? ex: dv.rowfilter = " Country = ' France ' " I want dv.rowfilter = " Title = (from...
2
by: Top Gun | last post by:
I am trying to code for a compound conditional in the DataView.RowFilter but don't quite no how to do the correct syntax for this. The following code sample chokes on dv.RowFilter: int batchid...
4
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...
8
by: KC | last post by:
For a DataView.Rowfilter can I use more than one expression? I want to filter out two different things. For example can I take: dv.RowFilter = "MTX <> 'Customer Forcast'" and ...
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...
0
by: neeraj | last post by:
Hi, all Could anny one give me help how can I use like operator with these data types "integer , datetime or boolean" in DataView.RowFilter Actually when I try to get the data from dataview...
2
by: neeraj | last post by:
Hi, all Could anny one give me help how can I use like operator with these data types "integer , datetime or boolean" in DataView.RowFilter Actually when I try to get the data from dataview...
1
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...
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.