in detail ado find problem

M

Michael

Hi all :


in vb6 while I use ado object .

I can use find method that allow me
do realtime search. e,g,

given table with one column "aField" as
aField
----------
abc
abd
acd
aed
afd

I define recordset rAdo
rAdo.find "aField >'" & sStr & "'"

while i type "ac" , the datagrid will locate the row in 3rd (is not filter)
However , in vb.net / ado.net. I have not any method to do this.

Can any one tell me how to do it ?

Thx


Michael
 
C

Cor Ligthert [MVP]

Michael,

Please don't multipost in this newsgroup you cannot expect that on what is
for most who are active here sunday evening or sunday night to get direct an
answer.

Thanks,

Cor
 
M

Michael

ok .

however, I have to study this article in serval time. It seems cannot help
solve the problem that

find method is only apply for full match key
however, I want find method is partial match key.
just like
rAdo.find "aField >'" & sStr & "'"
will integer nearest row.

do ado.net can help me ?

Thanks
 
C

CT

Michael,

The DataView, as pointed out by Cor, has the RowFilter property that'll help
you do that.
 
C

Cor Ligthert [MVP]

Michael,

You did not say that you want to find a partial word in the first
description of your problem. Please be more accurate in the description if
you have a problem.

For a find in a partial way (to find the index of the datasource) than your
only way can be in my opinion to loop through the datasource, or to find
with the *select* *Like* the rows with the full words and than extract
from the first datarow from that the full word to find the index .

http://msdn.microsoft.com/library/d.../frlrfsystemdatadatatableclassselecttopic.asp

However I would just go for a 'for index loop' in this case.

I hope this helps,

Cor
 
M

Michael

Cor .

I understand you have quite experience vb.net and want to help me solve. I'm
appreicate for your help first.
However, the problem is not very simple as you think. Right now I clarify my
requirement.
Given the table as "Customer",
In table "Customer", there have one column name
"CustomerName"

The table customer show as follow :
CustomerName
_______________
Able
Adware
Catherine
Cathy
Don
Donny

In vb6, I do the follow code which can allow me to create quick list
function

Dim rCustomer as recordset
rCustomer = new recordset
rCustomer.open ("select CustomerName from Customer" , sqlCnn)
set datagrid1.datasource = rCustomer

private sub SrhText_OnChange()
rCustomer.find "CustomerName >= '" & SrhText.Text & "'"
end sub
as a result , I type "Ca" , the cursor will go to 3rd row.
when I type "D", the cursor will go to 5th row.

In this case. vb.net find or findrow must fufill my requirement (or solve my
problem) since. Ca cannot find in the table. (i.e. "D" also cannot find) It
must return integer -1. (Mean no find).

In your second propose. You ask me use select method. However. Cor. select
method is a filter method or a find method. if you tell me use this method.
It is equal covert it into vb6 as follow :

Dim rCustomer as recordset
rCustomer = new recordset
rCustomer.open ("select CustomerName from Customer" , sqlCnn)
set datagrid1.datasource = rCustomer

private sub SrhText_OnChange()
rCustomer.filter = "CustomerName >= '" & SrhText.Text & "'"
end sub

Then when I type "Ca", the data
Able
Adware
will disappear unless I clear all word.

Finally, I just ado.net have method which return integer and move cursor
when I partical input. I know when to select, when to use find / findrow
metod.
find / findrow is move cursor, while select is use for filtering.

Cor. (expert vb.net developer) pls help me as vb.net beginner
or if you think I still stuck in somewhere. Please give me the sample code
base on above scenario.

Since I still evaluate feasibility between vb6 and vb.net

Thanks
 
C

Cor Ligthert [MVP]

Michael,

This sounds for me as an autocomplete combobox.
From which are very much samples on Internet.

This sample I made once for Bernie had an extra problem that it had to be
dropdownlist style.

http://groups.google.com/group/microsoft.public.dotnet.languages.vb/msg/706e937471d7cb3c?hl=en&

The main points are that you have to use the findstring (not the
findstringexact), use the keyup event and that you have to set the select
etc as you see in my sample.

I hope this is what you mean,

Cor
 
L

Lincon Marine Service

Cor.

Thanks
You can said that I want to create autocomplete function.
Combobox ideed can implement autocomplete function but have some restriction
behind this :

1. load list item must use for-loop-statment (when the data item have
100,000 it need to take 20 sec to complete) on the otherhand databind method
is faster,
2. traditional vb.net combo box only support single column. In some case, I
may have two or more column load combo box. (however , it seem combo box
cannot allow me to do this)

I have try to find many combo box (advance use). It show low proformance in
load list item, even it support multi-column
Right ?

if the table as follow :

CustomerName Phone
_______________ -------------------------------
Able 34-60-22000
Adware 34-61-22000
Catherine 23-20-11220
Cathy 12-10-12123
Don 45-21-12031
Donny 31-12-12032


in this case. combo box seem not commit my requirement.
BESIDES !!!
during, I drop the list , if I locate customername as index to find . I want
to change phone column as index and find. combo box must not allow me to do
this. right ?
This is a restriction of combobox and that's why I must ado.net with
databind method instead of use findstring in vb.net component.


ado in the past give me a "find method" function which allow me to do
autocomplete function in datagrid. but why ado.net cannot.
this is also my question.

Cor. as an expert in vb.net, I trust this simple problem, you can help me to
solve.

Thanks to you again.

But combo box have restriction . Create combo box
 
C

Cor Ligthert [MVP]

Michael,
What's the relation between currencymanager and auto complete function ?

Nothing, however with the currencymanager (current datarow manager) you can
synchronize the text in the textbox from the combobox with another textbox.

Cor
 
M

Michael

Cor ,

is it use for textbox or combo box ?
I will try to evaluate about this.

But it seem that .net really reduce auto-complete function which find
method / find row method functionality is must lower than vb6.

This give me disappointed

By the way thanks for Cor help. although the my problem still cannot solve.


Thanks

Michael
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top