Solved

Using a textbox to do a fuzzy lookup

Posted on 2006-11-13
6
508 Views
Last Modified: 2008-02-01
Hi there, the scenario of my problem is: A user can type in a string in a textbox, when he clicks the button the string must be used to do a fuzzy lookup with a reference table. If there is any similarities(where the _Similarity column > 0) between the string and a reference table it must show the fuzzyresults in a datagridview below the textbox.

Thanks.
0
Comment
Question by:cErasmus
6 Comments
 
LVL 2

Expert Comment

by:amiableansari
ID: 17929209

take a datatable and fill it with something that you want to show in datagrid

mDT = new DataTable();
mAdapter.Fill(mDT);                  
dgTest.DataSource = mDT;

now when the user clicks on the button make a dataview and add a filter expression and assign it to the datagrid.

private void button1_Click(object sender, System.EventArgs e)
{
        DataView mView = mDT.DefaultView;
      mView.RowFilter = "ur_ref_fieldname like '" + textBox1.Text + "%'";
      dgTest.DataSource = mView;
}

0
 
LVL 14

Expert Comment

by:nayernaguib
ID: 17929435
I think you missed another wildcard character before the text.

     mView.RowFilter = "ur_ref_fieldname like %'" + textBox1.Text + "%'";

_______________

  Nayer Naguib
0
 

Author Comment

by:cErasmus
ID: 17929436
I tried this, but like is not going to work for me. You see I want to, lets say a guy wants to buy a product, but first he has to check his stock so he enters the product's name, lets say he wants to buy a "Brown glasshouse" so he enters it. Now I check in stock, and in my stock I have "Brown glasscasing". Is this possible? I would like to use something like this in a front-end program? Doing a fuzzy search outside of SSIS?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 4

Accepted Solution

by:
tobydavid earned 500 total points
ID: 17932015
You might find Levenshtein Distance useful.  This is a measure of (dis)similarity between two strings based on the number of changes it would take to turn the first string into the second.  Here is a good source of additional information

http://www.merriampark.com/ld.htm

It also contains the code you would need for either Java, C++, or Visual Basic
0
 

Author Comment

by:cErasmus
ID: 17954502
Thanks, but I already solved it, i'll still reward you.
0
 
LVL 4

Expert Comment

by:tobydavid
ID: 17955499
Thank you.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now