Solved

How to find contents of a table in a string

Posted on 2008-06-11
4
189 Views
Last Modified: 2013-12-17
Given a string, usually a long sentence, how will I know if the contents of my table is part of that string.

ex. string = "the quick brown fox jump over the lazy dog"
myTableContents = dog, cat, fox, pig

I wanna get all the words from the string that exists in my table.  How will I do that using C#.net, and I'm using Access database.

0
Comment
Question by:meredithf
4 Comments
 
LVL 1

Accepted Solution

by:
miketob earned 125 total points
ID: 21762782
Use the split method to separate your sentence into words, it will result in an array of words, then cycle through this arry serching for each word in your table.

Regards

0
 
LVL 6

Expert Comment

by:Bruce_1975
ID: 21766851
Just to give you an other idea
Regards,
Bruce
string givenString = "the quick brown fox jump over the lazy dog";

foreach (string item in myTableContents)

{

    if (givenString.IndexOf(item) > -1)

        Debug.WriteLine(item + " is included");

}

Open in new window

0
 

Expert Comment

by:bmoabc
ID: 21772833
You can also return the resuts of a simple SQL if your table contents are unique records

SELECT table.[myTableContents]
FROM table
WHERE ((("sentence" Like "*" & table.[myTableContents] & "*")=True));

This will provide all the records send it to an array or another query, whatever you need...
0
 

Author Comment

by:meredithf
ID: 21809933
Thanks miketob for the idea.  It works.
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

867 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

24 Experts available now in Live!

Get 1:1 Help Now