dcsimg
Results 1 to 5 of 5

Thread: Possible to search enitre DataSet?

  1. #1

    Thread Starter
    Fanatic Member schoemr's Avatar
    Join Date
    Apr 2016
    Location
    South Africa
    Posts
    844

    Possible to search enitre DataSet?

    Hi,

    I have a dataset (from a SQL database) and this dataset contains many, many tables. Each table contain many columns.

    I want to find a specific string, but this string can be anywhere. I can search table for table but this will tame me a long time. Is it possible to search then entire dataset?

    For example I want to search "Michelle" I want to see in which tables is my name stored, and if possible what columns?

    Thanks
    Don't miss the whole point of the dance...

    https://www.youtube.com/watch?v=qHnIJeE3LAI

  2. #2
    PowerPoster TysonLPrice's Avatar
    Join Date
    Sep 2002
    Location
    Columbus, Ohio
    Posts
    3,202

    Re: Possible to search enitre DataSet?

    I don't see how you can get away without a table by table search unless maybe you dumped everything into some kind of huge flat file. There are plenty of examples using a SPROC though. I'd do the heavy lifting on the DB and return the results to a program. Here is an example...there are lots of them out there.

    https://hanssens.com/code/search-ent...cified-string/
    Please remember next time...elections matter!

  3. #3
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    101,271

    Re: Possible to search enitre DataSet?

    Think about what you're asking. A DataSet is basically just an in-memory representation of a database, where DataTables correspond to tables and DataRelations correspond to relations. Could you query a whole database without querying individual tables in it? Of course not. That wouldn't make any sense. That would be like searching a house without searching the rooms in the house.

  4. #4
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    33,136

    Re: Possible to search enitre DataSet?

    If you can't search against the database, and HAVE to search against the dataset, then you may well be able to speed the process up with threading. You mention many tables and many columns, but are there also many rows in each table?

    If there are many rows per table, then you might make a method that takes a column and searches that column. If there are not all that many rows per table (hundreds, or a few thousand, but not several thousand), then you might have the method take a table and search all the columns in that table. Then, spawn threads that call the method with the various elements (either columns or tables, depending on which level you want to break it down to). Most likely, it would be best to have the method search tables, because you won't be able to have a whole lot of concurrent threads performing the search, since each thread is probably going to be fully occupied.
    My usual boring signature: Nothing

  5. #5
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    101,271

    Re: Possible to search enitre DataSet?

    Shaggy, I was coming back to suggest something similar. As a first step, one could call Parallel.ForEach and search each DataTable in the DataSet in parallel, or at least more than one at a time. Of course, once you have too much going on at the same time, additional threads can't really help any further, hence the fact that the ThreadPool doesn't necessarily do everything at the same time.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width