Solved

How to find contents of a table in a string

Posted on 2008-06-11
4
188 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

759 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

19 Experts available now in Live!

Get 1:1 Help Now