473,499 Members | 1,589 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Datagrid findfirst findnext

I have been watching the dotnet newsgroups for a couple of weeks now and
scouring the net looking for a solution to my datagrid find functionality.
With no luck. I am hoping that you can help me.

I am an old VB6 coder used to using Sheridan controls, and I am just
starting to learn the .net world.

I am upgrading my music catalogue database, where the data is stored in an
Access mdb file.

The datagrid is bound to a dataview and I can get the find to work in that
it returns a valid row, but it is not the first row with that value.

Here is my search code
Dim dvData As DataView

Dim cmBkMrk As CurrencyManager

Dim intRec As Integer

dvData = Me.dgrCatalogue.DataSource

dvData.Sort = "Artist"

cmBkMrk = Me.dgrCatalogue.BindingContext(dvData)

intRec = dvData.Find("Triumph")

cmBkMrk.Position = intRec

It is finding the band Triumph, and moving to the found row, but it is not
the first row with the value Triumph. Why?

While I am here, I have three more questions:

1) How do I perform a FindNext?

2) How do I perform wildcard searches?

3) How do I perform searches on more than one column? I have figured out
how to sort on two columns, but what is the dvData.Find code?

Thanks In Advance!

Greg
Nov 21 '05 #1
9 3354
John,

I know that the dataview.find exist hower I did never use that one,
(probably because for that one the datarowcollection.find does(is) the same
and is easier to handle.

I think that you want more rows back and than the datarowfilter is easier to
handle.

The datarowfilter you set by (Keep in mind that the rowfilter is dynamicly
and reacts direct on the change of a filterfield) All is typed by hand in
this message so watch typos

\\\
dv.rowfilter = "MyFirstFindColomn = 'Whatever' AND MySecondColumn =
'SometingElse'"
//
(Mostly you have to make dynamicly a concatenated string, Think than to
enclose those in single quotes for string fields
\\\
For Each dvv As DataRowView In dv
dvv(0) = "Myfield"
Next
///
Or if you want that
\\\
For i as integer = 0 to dv.count-1
dv(i)(0) = "Myfield"
Next
///
I hope this helps?

Cor

"John Hernry" <jo********@sasktel.com>
I have been watching the dotnet newsgroups for a couple of weeks now and
scouring the net looking for a solution to my datagrid find functionality.
With no luck. I am hoping that you can help me.

I am an old VB6 coder used to using Sheridan controls, and I am just
starting to learn the .net world.

I am upgrading my music catalogue database, where the data is stored in an
Access mdb file.

The datagrid is bound to a dataview and I can get the find to work in that
it returns a valid row, but it is not the first row with that value.

Here is my search code
Dim dvData As DataView

Dim cmBkMrk As CurrencyManager

Dim intRec As Integer

dvData = Me.dgrCatalogue.DataSource

dvData.Sort = "Artist"

cmBkMrk = Me.dgrCatalogue.BindingContext(dvData)

intRec = dvData.Find("Triumph")

cmBkMrk.Position = intRec

It is finding the band Triumph, and moving to the found row, but it is not
the first row with the value Triumph. Why?

While I am here, I have three more questions:

1) How do I perform a FindNext?

2) How do I perform wildcard searches?

3) How do I perform searches on more than one column? I have figured out
how to sort on two columns, but what is the dvData.Find code?

Thanks In Advance!

Greg

Nov 21 '05 #2
Cor,
Thanks for the response. I have seen your responses to these type of
questions before and I was hoping you would respond.

Unfortunately, though, the filter isn't really what I'm after. I really
would like to keep all of the data visible so that the user can scroll
around in curiosity if need be. If you have ever used the find in Access I
am trying to build something along that line. Where I can specify criteria
such as: search in one field, all fields, at the beginning of the field, end
of the field, must match the entire field, or case sensitive etc. I suspect
that I am going to have to iterate through each field of each row based on
the search criteria. I was hoping for a quicker method as this method will
be slow. My database currently has 30,000 records with 5 fields: ID,
Source, Song, Artist, Album.

I have tried the filter method, and it would work as a last resort, but
ultimately it isn't what I'm after. Any other suggestions?

John
"Cor Ligthert" <no************@planet.nl> wrote in message
news:e4*************@TK2MSFTNGP11.phx.gbl...
John,

I know that the dataview.find exist hower I did never use that one,
(probably because for that one the datarowcollection.find does(is) the
same and is easier to handle.

I think that you want more rows back and than the datarowfilter is easier
to handle.

The datarowfilter you set by (Keep in mind that the rowfilter is dynamicly
and reacts direct on the change of a filterfield) All is typed by hand in
this message so watch typos

\\\
dv.rowfilter = "MyFirstFindColomn = 'Whatever' AND MySecondColumn =
'SometingElse'"
//
(Mostly you have to make dynamicly a concatenated string, Think than to
enclose those in single quotes for string fields
\\\
For Each dvv As DataRowView In dv
dvv(0) = "Myfield"
Next
///
Or if you want that
\\\
For i as integer = 0 to dv.count-1
dv(i)(0) = "Myfield"
Next
///
I hope this helps?

Cor

"John Hernry" <jo********@sasktel.com>
I have been watching the dotnet newsgroups for a couple of weeks now and
scouring the net looking for a solution to my datagrid find functionality.
With no luck. I am hoping that you can help me.

I am an old VB6 coder used to using Sheridan controls, and I am just
starting to learn the .net world.

I am upgrading my music catalogue database, where the data is stored in
an Access mdb file.

The datagrid is bound to a dataview and I can get the find to work in
that it returns a valid row, but it is not the first row with that value.

Here is my search code
Dim dvData As DataView

Dim cmBkMrk As CurrencyManager

Dim intRec As Integer

dvData = Me.dgrCatalogue.DataSource

dvData.Sort = "Artist"

cmBkMrk = Me.dgrCatalogue.BindingContext(dvData)

intRec = dvData.Find("Triumph")

cmBkMrk.Position = intRec

It is finding the band Triumph, and moving to the found row, but it is
not the first row with the value Triumph. Why?

While I am here, I have three more questions:

1) How do I perform a FindNext?

2) How do I perform wildcard searches?

3) How do I perform searches on more than one column? I have figured out
how to sort on two columns, but what is the dvData.Find code?

Thanks In Advance!

Greg


Nov 21 '05 #3
John,

When I started reading your question I thought, impossible and than I
thought, stupid me, of course that should be possible, probably a second
dataview will do exactly as you are asking for.

You can create as much dataviews you want from the same datatable.
I hope this is clear, otherwise tell it than I make a sample of it.

(While I am not familiar with the access find, so I hope this answer fits)

I hope this helps?

Cor

"John Hernry" <jo********@sasktel.com>
..
Cor,
Thanks for the response. I have seen your responses to these type of
questions before and I was hoping you would respond.

Unfortunately, though, the filter isn't really what I'm after. I really
would like to keep all of the data visible so that the user can scroll
around in curiosity if need be. If you have ever used the find in Access
I am trying to build something along that line. Where I can specify
criteria such as: search in one field, all fields, at the beginning of the
field, end of the field, must match the entire field, or case sensitive
etc. I suspect that I am going to have to iterate through each field of
each row based on the search criteria. I was hoping for a quicker method
as this method will be slow. My database currently has 30,000 records
with 5 fields: ID, Source, Song, Artist, Album.

I have tried the filter method, and it would work as a last resort, but
ultimately it isn't what I'm after. Any other suggestions?

John
"Cor Ligthert" <no************@planet.nl> wrote in message
news:e4*************@TK2MSFTNGP11.phx.gbl...
John,

I know that the dataview.find exist hower I did never use that one,
(probably because for that one the datarowcollection.find does(is) the
same and is easier to handle.

I think that you want more rows back and than the datarowfilter is easier
to handle.

The datarowfilter you set by (Keep in mind that the rowfilter is
dynamicly and reacts direct on the change of a filterfield) All is typed
by hand in this message so watch typos

\\\
dv.rowfilter = "MyFirstFindColomn = 'Whatever' AND MySecondColumn =
'SometingElse'"
//
(Mostly you have to make dynamicly a concatenated string, Think than to
enclose those in single quotes for string fields
\\\
For Each dvv As DataRowView In dv
dvv(0) = "Myfield"
Next
///
Or if you want that
\\\
For i as integer = 0 to dv.count-1
dv(i)(0) = "Myfield"
Next
///
I hope this helps?

Cor

"John Hernry" <jo********@sasktel.com>
I have been watching the dotnet newsgroups for a couple of weeks now and
scouring the net looking for a solution to my datagrid find
functionality. With no luck. I am hoping that you can help me.

I am an old VB6 coder used to using Sheridan controls, and I am just
starting to learn the .net world.

I am upgrading my music catalogue database, where the data is stored in
an Access mdb file.

The datagrid is bound to a dataview and I can get the find to work in
that it returns a valid row, but it is not the first row with that
value.

Here is my search code
Dim dvData As DataView

Dim cmBkMrk As CurrencyManager

Dim intRec As Integer

dvData = Me.dgrCatalogue.DataSource

dvData.Sort = "Artist"

cmBkMrk = Me.dgrCatalogue.BindingContext(dvData)

intRec = dvData.Find("Triumph")

cmBkMrk.Position = intRec

It is finding the band Triumph, and moving to the found row, but it is
not the first row with the value Triumph. Why?

While I am here, I have three more questions:

1) How do I perform a FindNext?

2) How do I perform wildcard searches?

3) How do I perform searches on more than one column? I have figured
out how to sort on two columns, but what is the dvData.Find code?

Thanks In Advance!

Greg



Nov 21 '05 #4
Cor,
So, If I understand you correctly, you are saying to create a second
dataview of the table, do my filter on it, find the record I need (which
will likely have to still be done by looping through the filtered records,
but at least far less of them), get the unique ID from the found record then
find that ID on the displayed dataview and move to that record. Is that
about right?

John

"Cor Ligthert" <no************@planet.nl> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
John,

When I started reading your question I thought, impossible and than I
thought, stupid me, of course that should be possible, probably a second
dataview will do exactly as you are asking for.

You can create as much dataviews you want from the same datatable.
I hope this is clear, otherwise tell it than I make a sample of it.

(While I am not familiar with the access find, so I hope this answer fits)

I hope this helps?

Cor

"John Hernry" <jo********@sasktel.com>
.
Cor,
Thanks for the response. I have seen your responses to these type of
questions before and I was hoping you would respond.

Unfortunately, though, the filter isn't really what I'm after. I really
would like to keep all of the data visible so that the user can scroll
around in curiosity if need be. If you have ever used the find in Access
I am trying to build something along that line. Where I can specify
criteria such as: search in one field, all fields, at the beginning of
the field, end of the field, must match the entire field, or case
sensitive etc. I suspect that I am going to have to iterate through each
field of each row based on the search criteria. I was hoping for a
quicker method as this method will be slow. My database currently has
30,000 records with 5 fields: ID, Source, Song, Artist, Album.

I have tried the filter method, and it would work as a last resort, but
ultimately it isn't what I'm after. Any other suggestions?

John
"Cor Ligthert" <no************@planet.nl> wrote in message
news:e4*************@TK2MSFTNGP11.phx.gbl...
John,

I know that the dataview.find exist hower I did never use that one,
(probably because for that one the datarowcollection.find does(is) the
same and is easier to handle.

I think that you want more rows back and than the datarowfilter is
easier to handle.

The datarowfilter you set by (Keep in mind that the rowfilter is
dynamicly and reacts direct on the change of a filterfield) All is typed
by hand in this message so watch typos

\\\
dv.rowfilter = "MyFirstFindColomn = 'Whatever' AND MySecondColumn =
'SometingElse'"
//
(Mostly you have to make dynamicly a concatenated string, Think than to
enclose those in single quotes for string fields
\\\
For Each dvv As DataRowView In dv
dvv(0) = "Myfield"
Next
///
Or if you want that
\\\
For i as integer = 0 to dv.count-1
dv(i)(0) = "Myfield"
Next
///
I hope this helps?

Cor

"John Hernry" <jo********@sasktel.com>
I have been watching the dotnet newsgroups for a couple of weeks now and
scouring the net looking for a solution to my datagrid find
functionality. With no luck. I am hoping that you can help me.

I am an old VB6 coder used to using Sheridan controls, and I am just
starting to learn the .net world.

I am upgrading my music catalogue database, where the data is stored in
an Access mdb file.

The datagrid is bound to a dataview and I can get the find to work in
that it returns a valid row, but it is not the first row with that
value.

Here is my search code
Dim dvData As DataView

Dim cmBkMrk As CurrencyManager

Dim intRec As Integer

dvData = Me.dgrCatalogue.DataSource

dvData.Sort = "Artist"

cmBkMrk = Me.dgrCatalogue.BindingContext(dvData)

intRec = dvData.Find("Triumph")

cmBkMrk.Position = intRec

It is finding the band Triumph, and moving to the found row, but it is
not the first row with the value Triumph. Why?

While I am here, I have three more questions:

1) How do I perform a FindNext?

2) How do I perform wildcard searches?

3) How do I perform searches on more than one column? I have figured
out how to sort on two columns, but what is the dvData.Find code?

Thanks In Advance!

Greg



Nov 21 '05 #5
John,

Seeing it again now I think that you are after this as the sample bellow?

It is very fast made, it is saterdaynight here you know

Cor

\\\
Private dtVBreg As DataTable

Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
CreateTables()
Dim dv As New DataView(dtVBreg)
DataGrid1.DataSource = dv
Dim cm As CurrencyManager
cm = CType(BindingContext(dv), CurrencyManager)
dv.Sort = "Name,Country"
Dim findObject(1) As Object
findObject(0) = "Terry Burns"
findObject(1) = "EU"
cm.Position = dv.Find(findObject)
DataGrid1.Select(cm.Position)
End Sub
Private Sub CreateTables()
Dim drel As DataRelation
dtVBreg = New DataTable("Persons")
dtVBreg.Columns.Add("Name")
dtVBreg.Columns.Add("Country")
For i As Integer = 0 To 7
dtVBreg.Rows.Add(dtVBreg.NewRow)
Next
dtVBreg.Rows(0).ItemArray = New Object() _
{"Herfried K. Wagner", "EU"}
dtVBreg.Rows(1).ItemArray = New Object() _
{"Ken Tucker", "US"}
dtVBreg.Rows(2).ItemArray = New Object() _
{"CJ Taylor", "US"}
dtVBreg.Rows(3).ItemArray = New Object() _
{"Jay B Harlow", "US"}
dtVBreg.Rows(4).ItemArray = New Object() _
{"Terry Burns", "EU"}
dtVBreg.Rows(5).ItemArray = New Object() _
{"Tom Shelton", "US"}
dtVBreg.Rows(6).ItemArray = New Object() _
{"Cor Ligthert", "EU"}
End Sub
///
"John Hernry" <jo********@sasktel.com>
....
Cor,
So, If I understand you correctly, you are saying to create a second
dataview of the table, do my filter on it, find the record I need (which
will likely have to still be done by looping through the filtered records,
but at least far less of them), get the unique ID from the found record
then find that ID on the displayed dataview and move to that record. Is
that about right?

John

"Cor Ligthert" <no************@planet.nl> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
John,

When I started reading your question I thought, impossible and than I
thought, stupid me, of course that should be possible, probably a second
dataview will do exactly as you are asking for.

You can create as much dataviews you want from the same datatable.
I hope this is clear, otherwise tell it than I make a sample of it.

(While I am not familiar with the access find, so I hope this answer
fits)

I hope this helps?

Cor

"John Hernry" <jo********@sasktel.com>
.
Cor,
Thanks for the response. I have seen your responses to these type of
questions before and I was hoping you would respond.

Unfortunately, though, the filter isn't really what I'm after. I really
would like to keep all of the data visible so that the user can scroll
around in curiosity if need be. If you have ever used the find in
Access I am trying to build something along that line. Where I can
specify criteria such as: search in one field, all fields, at the
beginning of the field, end of the field, must match the entire field,
or case sensitive etc. I suspect that I am going to have to iterate
through each field of each row based on the search criteria. I was
hoping for a quicker method as this method will be slow. My database
currently has 30,000 records with 5 fields: ID, Source, Song, Artist,
Album.

I have tried the filter method, and it would work as a last resort, but
ultimately it isn't what I'm after. Any other suggestions?

John
"Cor Ligthert" <no************@planet.nl> wrote in message
news:e4*************@TK2MSFTNGP11.phx.gbl...
John,

I know that the dataview.find exist hower I did never use that one,
(probably because for that one the datarowcollection.find does(is) the
same and is easier to handle.

I think that you want more rows back and than the datarowfilter is
easier to handle.

The datarowfilter you set by (Keep in mind that the rowfilter is
dynamicly and reacts direct on the change of a filterfield) All is
typed by hand in this message so watch typos

\\\
dv.rowfilter = "MyFirstFindColomn = 'Whatever' AND MySecondColumn =
'SometingElse'"
//
(Mostly you have to make dynamicly a concatenated string, Think than to
enclose those in single quotes for string fields
\\\
For Each dvv As DataRowView In dv
dvv(0) = "Myfield"
Next
///
Or if you want that
\\\
For i as integer = 0 to dv.count-1
dv(i)(0) = "Myfield"
Next
///
I hope this helps?

Cor

"John Hernry" <jo********@sasktel.com>
>I have been watching the dotnet newsgroups for a couple of weeks now
>and scouring the net looking for a solution to my datagrid find
>functionality. With no luck. I am hoping that you can help me.
>
> I am an old VB6 coder used to using Sheridan controls, and I am just
> starting to learn the .net world.
>
> I am upgrading my music catalogue database, where the data is stored
> in an Access mdb file.
>
> The datagrid is bound to a dataview and I can get the find to work in
> that it returns a valid row, but it is not the first row with that
> value.
>
> Here is my search code
> Dim dvData As DataView
>
> Dim cmBkMrk As CurrencyManager
>
> Dim intRec As Integer
>
> dvData = Me.dgrCatalogue.DataSource
>
> dvData.Sort = "Artist"
>
> cmBkMrk = Me.dgrCatalogue.BindingContext(dvData)
>
> intRec = dvData.Find("Triumph")
>
> cmBkMrk.Position = intRec
>
> It is finding the band Triumph, and moving to the found row, but it is
> not the first row with the value Triumph. Why?
>
> While I am here, I have three more questions:
>
> 1) How do I perform a FindNext?
>
> 2) How do I perform wildcard searches?
>
> 3) How do I perform searches on more than one column? I have figured
> out how to sort on two columns, but what is the dvData.Find code?
>
>
>
> Thanks In Advance!
>
> Greg
>
>



Nov 21 '05 #6
Cor,
I have done this type of find, which initiated this posting. There are two
inherent problems. One - No wildcard searches. Two - Because my search
value is not unique, it does not necessarily return the first value (bug?).
This find will only find exact matches and I really am looking for wildcard
type searches without having to use a filter.

The find must also be able to perform a find next. So I would be able to
begin my search from a specified row.

John

"Cor Ligthert" <no************@planet.nl> wrote in message
news:Os**************@TK2MSFTNGP14.phx.gbl...
John,

Seeing it again now I think that you are after this as the sample bellow?

It is very fast made, it is saterdaynight here you know

Cor

\\\
Private dtVBreg As DataTable

Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
CreateTables()
Dim dv As New DataView(dtVBreg)
DataGrid1.DataSource = dv
Dim cm As CurrencyManager
cm = CType(BindingContext(dv), CurrencyManager)
dv.Sort = "Name,Country"
Dim findObject(1) As Object
findObject(0) = "Terry Burns"
findObject(1) = "EU"
cm.Position = dv.Find(findObject)
DataGrid1.Select(cm.Position)
End Sub
Private Sub CreateTables()
Dim drel As DataRelation
dtVBreg = New DataTable("Persons")
dtVBreg.Columns.Add("Name")
dtVBreg.Columns.Add("Country")
For i As Integer = 0 To 7
dtVBreg.Rows.Add(dtVBreg.NewRow)
Next
dtVBreg.Rows(0).ItemArray = New Object() _
{"Herfried K. Wagner", "EU"}
dtVBreg.Rows(1).ItemArray = New Object() _
{"Ken Tucker", "US"}
dtVBreg.Rows(2).ItemArray = New Object() _
{"CJ Taylor", "US"}
dtVBreg.Rows(3).ItemArray = New Object() _
{"Jay B Harlow", "US"}
dtVBreg.Rows(4).ItemArray = New Object() _
{"Terry Burns", "EU"}
dtVBreg.Rows(5).ItemArray = New Object() _
{"Tom Shelton", "US"}
dtVBreg.Rows(6).ItemArray = New Object() _
{"Cor Ligthert", "EU"}
End Sub
///
"John Hernry" <jo********@sasktel.com>
...
Cor,
So, If I understand you correctly, you are saying to create a second
dataview of the table, do my filter on it, find the record I need (which
will likely have to still be done by looping through the filtered
records, but at least far less of them), get the unique ID from the found
record then find that ID on the displayed dataview and move to that
record. Is that about right?

John

"Cor Ligthert" <no************@planet.nl> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
John,

When I started reading your question I thought, impossible and than I
thought, stupid me, of course that should be possible, probably a
second dataview will do exactly as you are asking for.

You can create as much dataviews you want from the same datatable.
I hope this is clear, otherwise tell it than I make a sample of it.

(While I am not familiar with the access find, so I hope this answer
fits)

I hope this helps?

Cor

"John Hernry" <jo********@sasktel.com>
.
Cor,
Thanks for the response. I have seen your responses to these type of
questions before and I was hoping you would respond.

Unfortunately, though, the filter isn't really what I'm after. I
really would like to keep all of the data visible so that the user can
scroll around in curiosity if need be. If you have ever used the find
in Access I am trying to build something along that line. Where I can
specify criteria such as: search in one field, all fields, at the
beginning of the field, end of the field, must match the entire field,
or case sensitive etc. I suspect that I am going to have to iterate
through each field of each row based on the search criteria. I was
hoping for a quicker method as this method will be slow. My database
currently has 30,000 records with 5 fields: ID, Source, Song, Artist,
Album.

I have tried the filter method, and it would work as a last resort, but
ultimately it isn't what I'm after. Any other suggestions?

John
"Cor Ligthert" <no************@planet.nl> wrote in message
news:e4*************@TK2MSFTNGP11.phx.gbl...
> John,
>
> I know that the dataview.find exist hower I did never use that one,
> (probably because for that one the datarowcollection.find does(is) the
> same and is easier to handle.
>
> I think that you want more rows back and than the datarowfilter is
> easier to handle.
>
> The datarowfilter you set by (Keep in mind that the rowfilter is
> dynamicly and reacts direct on the change of a filterfield) All is
> typed by hand in this message so watch typos
>
> \\\
> dv.rowfilter = "MyFirstFindColomn = 'Whatever' AND MySecondColumn =
> 'SometingElse'"
> //
> (Mostly you have to make dynamicly a concatenated string, Think than
> to enclose those in single quotes for string fields
> \\\
> For Each dvv As DataRowView In dv
> dvv(0) = "Myfield"
> Next
> ///
> Or if you want that
> \\\
> For i as integer = 0 to dv.count-1
> dv(i)(0) = "Myfield"
> Next
> ///
> I hope this helps?
>
> Cor
>
> "John Hernry" <jo********@sasktel.com>
>>I have been watching the dotnet newsgroups for a couple of weeks now
>>and scouring the net looking for a solution to my datagrid find
>>functionality. With no luck. I am hoping that you can help me.
>>
>> I am an old VB6 coder used to using Sheridan controls, and I am just
>> starting to learn the .net world.
>>
>> I am upgrading my music catalogue database, where the data is stored
>> in an Access mdb file.
>>
>> The datagrid is bound to a dataview and I can get the find to work in
>> that it returns a valid row, but it is not the first row with that
>> value.
>>
>> Here is my search code
>> Dim dvData As DataView
>>
>> Dim cmBkMrk As CurrencyManager
>>
>> Dim intRec As Integer
>>
>> dvData = Me.dgrCatalogue.DataSource
>>
>> dvData.Sort = "Artist"
>>
>> cmBkMrk = Me.dgrCatalogue.BindingContext(dvData)
>>
>> intRec = dvData.Find("Triumph")
>>
>> cmBkMrk.Position = intRec
>>
>> It is finding the band Triumph, and moving to the found row, but it
>> is not the first row with the value Triumph. Why?
>>
>> While I am here, I have three more questions:
>>
>> 1) How do I perform a FindNext?
>>
>> 2) How do I perform wildcard searches?
>>
>> 3) How do I perform searches on more than one column? I have figured
>> out how to sort on two columns, but what is the dvData.Find code?
>>
>>
>>
>> Thanks In Advance!
>>
>> Greg
>>
>>
>
>



Nov 21 '05 #7
John, go to : http://www.planetsourcecode.com/

And search for a program called: DataEasy. It is a VB.NET program(with
source code) that will open any Access Database and allow searching
different columns(user selected) and what I like is that as you type into
the textbox it starts the search and picks all records in that field that
match what you are typing.
And it is pretty fast too.
Maybe, that will give you a couple of ideas.
james

"John Hernry" <jo********@sasktel.com> wrote in message
news:e8**************@TK2MSFTNGP09.phx.gbl...
Cor,
I have done this type of find, which initiated this posting. There are
two inherent problems. One - No wildcard searches. Two - Because my
search value is not unique, it does not necessarily return the first value
(bug?). This find will only find exact matches and I really am looking for
wildcard type searches without having to use a filter.

The find must also be able to perform a find next. So I would be able to
begin my search from a specified row.

John

"Cor Ligthert" <no************@planet.nl> wrote in message
news:Os**************@TK2MSFTNGP14.phx.gbl...
John,

Seeing it again now I think that you are after this as the sample bellow?

It is very fast made, it is saterdaynight here you know

Cor

\\\
Private dtVBreg As DataTable

Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
CreateTables()
Dim dv As New DataView(dtVBreg)
DataGrid1.DataSource = dv
Dim cm As CurrencyManager
cm = CType(BindingContext(dv), CurrencyManager)
dv.Sort = "Name,Country"
Dim findObject(1) As Object
findObject(0) = "Terry Burns"
findObject(1) = "EU"
cm.Position = dv.Find(findObject)
DataGrid1.Select(cm.Position)
End Sub
Private Sub CreateTables()
Dim drel As DataRelation
dtVBreg = New DataTable("Persons")
dtVBreg.Columns.Add("Name")
dtVBreg.Columns.Add("Country")
For i As Integer = 0 To 7
dtVBreg.Rows.Add(dtVBreg.NewRow)
Next
dtVBreg.Rows(0).ItemArray = New Object() _
{"Herfried K. Wagner", "EU"}
dtVBreg.Rows(1).ItemArray = New Object() _
{"Ken Tucker", "US"}
dtVBreg.Rows(2).ItemArray = New Object() _
{"CJ Taylor", "US"}
dtVBreg.Rows(3).ItemArray = New Object() _
{"Jay B Harlow", "US"}
dtVBreg.Rows(4).ItemArray = New Object() _
{"Terry Burns", "EU"}
dtVBreg.Rows(5).ItemArray = New Object() _
{"Tom Shelton", "US"}
dtVBreg.Rows(6).ItemArray = New Object() _
{"Cor Ligthert", "EU"}
End Sub
///
"John Hernry" <jo********@sasktel.com>
...
Cor,
So, If I understand you correctly, you are saying to create a second
dataview of the table, do my filter on it, find the record I need (which
will likely have to still be done by looping through the filtered
records, but at least far less of them), get the unique ID from the
found record then find that ID on the displayed dataview and move to
that record. Is that about right?

John

"Cor Ligthert" <no************@planet.nl> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
John,

When I started reading your question I thought, impossible and than I
thought, stupid me, of course that should be possible, probably a
second dataview will do exactly as you are asking for.

You can create as much dataviews you want from the same datatable.
I hope this is clear, otherwise tell it than I make a sample of it.

(While I am not familiar with the access find, so I hope this answer
fits)

I hope this helps?

Cor

"John Hernry" <jo********@sasktel.com>
.
> Cor,
> Thanks for the response. I have seen your responses to these type of
> questions before and I was hoping you would respond.
>
> Unfortunately, though, the filter isn't really what I'm after. I
> really would like to keep all of the data visible so that the user can
> scroll around in curiosity if need be. If you have ever used the find
> in Access I am trying to build something along that line. Where I can
> specify criteria such as: search in one field, all fields, at the
> beginning of the field, end of the field, must match the entire field,
> or case sensitive etc. I suspect that I am going to have to iterate
> through each field of each row based on the search criteria. I was
> hoping for a quicker method as this method will be slow. My database
> currently has 30,000 records with 5 fields: ID, Source, Song, Artist,
> Album.
>
> I have tried the filter method, and it would work as a last resort,
> but ultimately it isn't what I'm after. Any other suggestions?
>
> John
>
>
> "Cor Ligthert" <no************@planet.nl> wrote in message
> news:e4*************@TK2MSFTNGP11.phx.gbl...
>> John,
>>
>> I know that the dataview.find exist hower I did never use that one,
>> (probably because for that one the datarowcollection.find does(is)
>> the same and is easier to handle.
>>
>> I think that you want more rows back and than the datarowfilter is
>> easier to handle.
>>
>> The datarowfilter you set by (Keep in mind that the rowfilter is
>> dynamicly and reacts direct on the change of a filterfield) All is
>> typed by hand in this message so watch typos
>>
>> \\\
>> dv.rowfilter = "MyFirstFindColomn = 'Whatever' AND MySecondColumn =
>> 'SometingElse'"
>> //
>> (Mostly you have to make dynamicly a concatenated string, Think than
>> to enclose those in single quotes for string fields
>> \\\
>> For Each dvv As DataRowView In dv
>> dvv(0) = "Myfield"
>> Next
>> ///
>> Or if you want that
>> \\\
>> For i as integer = 0 to dv.count-1
>> dv(i)(0) = "Myfield"
>> Next
>> ///
>> I hope this helps?
>>
>> Cor
>>
>> "John Hernry" <jo********@sasktel.com>
>>>I have been watching the dotnet newsgroups for a couple of weeks now
>>>and scouring the net looking for a solution to my datagrid find
>>>functionality. With no luck. I am hoping that you can help me.
>>>
>>> I am an old VB6 coder used to using Sheridan controls, and I am just
>>> starting to learn the .net world.
>>>
>>> I am upgrading my music catalogue database, where the data is stored
>>> in an Access mdb file.
>>>
>>> The datagrid is bound to a dataview and I can get the find to work
>>> in that it returns a valid row, but it is not the first row with
>>> that value.
>>>
>>> Here is my search code
>>> Dim dvData As DataView
>>>
>>> Dim cmBkMrk As CurrencyManager
>>>
>>> Dim intRec As Integer
>>>
>>> dvData = Me.dgrCatalogue.DataSource
>>>
>>> dvData.Sort = "Artist"
>>>
>>> cmBkMrk = Me.dgrCatalogue.BindingContext(dvData)
>>>
>>> intRec = dvData.Find("Triumph")
>>>
>>> cmBkMrk.Position = intRec
>>>
>>> It is finding the band Triumph, and moving to the found row, but it
>>> is not the first row with the value Triumph. Why?
>>>
>>> While I am here, I have three more questions:
>>>
>>> 1) How do I perform a FindNext?
>>>
>>> 2) How do I perform wildcard searches?
>>>
>>> 3) How do I perform searches on more than one column? I have
>>> figured out how to sort on two columns, but what is the dvData.Find
>>> code?
>>>
>>>
>>>
>>> Thanks In Advance!
>>>
>>> Greg
>>>
>>>
>>
>>
>
>



Nov 21 '05 #8
John,

All thougether is that what I am expecting while I sand my last message
however a newsgroup is difficult for that to communicate and this kind of
things have in my opinion to be done step by step.

My solution would be to do a search using the datarowfilter in an extra
dataview.
Than when the result is more than one, I would let the user choose from
those in an extra datagrid. When it is one, you have it direct and with zero
there should be a message.

Than you can use the solution I gave you as last one before this with the
dataview.find with only the ID to get the exact row in the main dataview,
datagrid.

I think that this will be a good solution.
(When you do not want the selection form on your screen you can make a
showdialog form for that, remember that you have only give the dv's by value
than everything is done, because that is a reference to the used dv's)

I hope this gives some ideas?

Cor

"John Hernry" <jo********@sasktel.com>
Cor,
I have done this type of find, which initiated this posting. There are
two inherent problems. One - No wildcard searches. Two - Because my
search value is not unique, it does not necessarily return the first value
(bug?). This find will only find exact matches and I really am looking for
wildcard type searches without having to use a filter.

The find must also be able to perform a find next. So I would be able to
begin my search from a specified row.

John

"Cor Ligthert" <no************@planet.nl> wrote in message
news:Os**************@TK2MSFTNGP14.phx.gbl...
John,

Seeing it again now I think that you are after this as the sample bellow?

It is very fast made, it is saterdaynight here you know

Cor

\\\
Private dtVBreg As DataTable

Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
CreateTables()
Dim dv As New DataView(dtVBreg)
DataGrid1.DataSource = dv
Dim cm As CurrencyManager
cm = CType(BindingContext(dv), CurrencyManager)
dv.Sort = "Name,Country"
Dim findObject(1) As Object
findObject(0) = "Terry Burns"
findObject(1) = "EU"
cm.Position = dv.Find(findObject)
DataGrid1.Select(cm.Position)
End Sub
Private Sub CreateTables()
Dim drel As DataRelation
dtVBreg = New DataTable("Persons")
dtVBreg.Columns.Add("Name")
dtVBreg.Columns.Add("Country")
For i As Integer = 0 To 7
dtVBreg.Rows.Add(dtVBreg.NewRow)
Next
dtVBreg.Rows(0).ItemArray = New Object() _
{"Herfried K. Wagner", "EU"}
dtVBreg.Rows(1).ItemArray = New Object() _
{"Ken Tucker", "US"}
dtVBreg.Rows(2).ItemArray = New Object() _
{"CJ Taylor", "US"}
dtVBreg.Rows(3).ItemArray = New Object() _
{"Jay B Harlow", "US"}
dtVBreg.Rows(4).ItemArray = New Object() _
{"Terry Burns", "EU"}
dtVBreg.Rows(5).ItemArray = New Object() _
{"Tom Shelton", "US"}
dtVBreg.Rows(6).ItemArray = New Object() _
{"Cor Ligthert", "EU"}
End Sub
///
"John Hernry" <jo********@sasktel.com>
...
Cor,
So, If I understand you correctly, you are saying to create a second
dataview of the table, do my filter on it, find the record I need (which
will likely have to still be done by looping through the filtered
records, but at least far less of them), get the unique ID from the
found record then find that ID on the displayed dataview and move to
that record. Is that about right?

John

"Cor Ligthert" <no************@planet.nl> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
John,

When I started reading your question I thought, impossible and than I
thought, stupid me, of course that should be possible, probably a
second dataview will do exactly as you are asking for.

You can create as much dataviews you want from the same datatable.
I hope this is clear, otherwise tell it than I make a sample of it.

(While I am not familiar with the access find, so I hope this answer
fits)

I hope this helps?

Cor

"John Hernry" <jo********@sasktel.com>
.
> Cor,
> Thanks for the response. I have seen your responses to these type of
> questions before and I was hoping you would respond.
>
> Unfortunately, though, the filter isn't really what I'm after. I
> really would like to keep all of the data visible so that the user can
> scroll around in curiosity if need be. If you have ever used the find
> in Access I am trying to build something along that line. Where I can
> specify criteria such as: search in one field, all fields, at the
> beginning of the field, end of the field, must match the entire field,
> or case sensitive etc. I suspect that I am going to have to iterate
> through each field of each row based on the search criteria. I was
> hoping for a quicker method as this method will be slow. My database
> currently has 30,000 records with 5 fields: ID, Source, Song, Artist,
> Album.
>
> I have tried the filter method, and it would work as a last resort,
> but ultimately it isn't what I'm after. Any other suggestions?
>
> John
>
>
> "Cor Ligthert" <no************@planet.nl> wrote in message
> news:e4*************@TK2MSFTNGP11.phx.gbl...
>> John,
>>
>> I know that the dataview.find exist hower I did never use that one,
>> (probably because for that one the datarowcollection.find does(is)
>> the same and is easier to handle.
>>
>> I think that you want more rows back and than the datarowfilter is
>> easier to handle.
>>
>> The datarowfilter you set by (Keep in mind that the rowfilter is
>> dynamicly and reacts direct on the change of a filterfield) All is
>> typed by hand in this message so watch typos
>>
>> \\\
>> dv.rowfilter = "MyFirstFindColomn = 'Whatever' AND MySecondColumn =
>> 'SometingElse'"
>> //
>> (Mostly you have to make dynamicly a concatenated string, Think than
>> to enclose those in single quotes for string fields
>> \\\
>> For Each dvv As DataRowView In dv
>> dvv(0) = "Myfield"
>> Next
>> ///
>> Or if you want that
>> \\\
>> For i as integer = 0 to dv.count-1
>> dv(i)(0) = "Myfield"
>> Next
>> ///
>> I hope this helps?
>>
>> Cor
>>
>> "John Hernry" <jo********@sasktel.com>
>>>I have been watching the dotnet newsgroups for a couple of weeks now
>>>and scouring the net looking for a solution to my datagrid find
>>>functionality. With no luck. I am hoping that you can help me.
>>>
>>> I am an old VB6 coder used to using Sheridan controls, and I am just
>>> starting to learn the .net world.
>>>
>>> I am upgrading my music catalogue database, where the data is stored
>>> in an Access mdb file.
>>>
>>> The datagrid is bound to a dataview and I can get the find to work
>>> in that it returns a valid row, but it is not the first row with
>>> that value.
>>>
>>> Here is my search code
>>> Dim dvData As DataView
>>>
>>> Dim cmBkMrk As CurrencyManager
>>>
>>> Dim intRec As Integer
>>>
>>> dvData = Me.dgrCatalogue.DataSource
>>>
>>> dvData.Sort = "Artist"
>>>
>>> cmBkMrk = Me.dgrCatalogue.BindingContext(dvData)
>>>
>>> intRec = dvData.Find("Triumph")
>>>
>>> cmBkMrk.Position = intRec
>>>
>>> It is finding the band Triumph, and moving to the found row, but it
>>> is not the first row with the value Triumph. Why?
>>>
>>> While I am here, I have three more questions:
>>>
>>> 1) How do I perform a FindNext?
>>>
>>> 2) How do I perform wildcard searches?
>>>
>>> 3) How do I perform searches on more than one column? I have
>>> figured out how to sort on two columns, but what is the dvData.Find
>>> code?
>>>
>>>
>>>
>>> Thanks In Advance!
>>>
>>> Greg
>>>
>>>
>>
>>
>
>



Nov 21 '05 #9
Cor and James,
Thank you for your responses. I have taken all of your suggestions and will
be putting them into action on my project.

John

"John Hernry" <jo********@sasktel.com> wrote in message
news:e6**************@TK2MSFTNGP09.phx.gbl...
I have been watching the dotnet newsgroups for a couple of weeks now and
scouring the net looking for a solution to my datagrid find functionality.
With no luck. I am hoping that you can help me.

I am an old VB6 coder used to using Sheridan controls, and I am just
starting to learn the .net world.

I am upgrading my music catalogue database, where the data is stored in an
Access mdb file.

The datagrid is bound to a dataview and I can get the find to work in that
it returns a valid row, but it is not the first row with that value.

Here is my search code
Dim dvData As DataView

Dim cmBkMrk As CurrencyManager

Dim intRec As Integer

dvData = Me.dgrCatalogue.DataSource

dvData.Sort = "Artist"

cmBkMrk = Me.dgrCatalogue.BindingContext(dvData)

intRec = dvData.Find("Triumph")

cmBkMrk.Position = intRec

It is finding the band Triumph, and moving to the found row, but it is not
the first row with the value Triumph. Why?

While I am here, I have three more questions:

1) How do I perform a FindNext?

2) How do I perform wildcard searches?

3) How do I perform searches on more than one column? I have figured out
how to sort on two columns, but what is the dvData.Find code?

Thanks In Advance!

Greg

Nov 21 '05 #10

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

Similar topics

5
4365
by: Mike | last post by:
Hi I've written a module to find the first occurrence of a record in a query (that is my forms datasource) that matches four specified criteria. No matter what I try it doesn't seem to find ...
3
4234
by: Bill C. | last post by:
Hello, I know this has been discussed a lot already because I've been searching around for information the last few weeks. I'm trying to implement a DataGridComboBoxColumn class. I've found...
1
2916
by: bmshirey | last post by:
I have a program which manages various log files of multiple extensions. The program needs to delete files based on an age paramter and a file number limit paramter. So if files are older than say...
0
1784
by: JC | last post by:
I have a list box loaded with Student Name, Social Security. When the user click on a specific record, the following code is assigned to the lstStudent1_AfterUpdate procedure. Private Sub...
2
2431
by: keri | last post by:
Hi everyone, I'm using findfirst in code as below. It searches a query that shows appointment date and account name and should return the account name of the first appointment on each day into...
1
6680
Corster
by: Corster | last post by:
I went through a great deal of hassle to figure this out for myself, but now it is complete, I would like to share it with the world! I know afew other people have had trouble with FindFirst and...
25
3886
by: Rick Collard | last post by:
Using DAO 3.6 on an Access 2002 database, I'm getting unexpected results with the FindFirst method. Here's the simple code to test: Public Sub FindIt() Dim db As Database, rs As Recordset...
0
2301
by: bitstreamer | last post by:
Greetings everybody, I'm trying to UNDERSTAND this code. I've already done lots and lots of debugging sessions and I can confirm that the FIND_NEXT routine is never executed. Every file entry...
13
16933
by: ChrisD76 | last post by:
Hi, I am new to using VBA, and have been working with DAO Recordsets. I'm working on a little problem, and think that DAO Recordsets are the solution. I've been playing around with them to try and...
0
7132
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
7178
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
7223
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
7390
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5475
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,...
0
3103
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3094
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1427
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
302
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...

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.