473,542 Members | 16,331 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ADO Scallable Search

I have a database of 200+ tables (two tables per school), each with 100 -
4000 records (one record per student). A contract I'm looking at wants to
be able to do a search across all the tables, searching for values a user
inputs via a Search form.

I have a solution, but I don't think it'll work on large scales.

Is there a better bet then querying table 1, finding matching values and
writing those records into an ADO variable, closing that table, then moving
on to the next table etc?

That seems a very brute force method to me.

<Ade
--
Adrian Parker. Ordained priest. <ad***********@sympatico.ca>
Want to know the purpose of life? I'd be happy to share it with you...
Jul 17 '05 #1
11 3782
You could do it all in SQL and create a temp table for the results. if all
200 Table have the same structure (which I assume they do here, you'd need a
series of (Idealy adding perhaps a SchoolID field to a table and filtering
all records by School ID instead of having a table per school would save you
a lot of time for this :-).

SELECT INTO <TempTableName> * FROM <TableName> WHERE <ListOfCriteria>

Depending on Database type (MySQL, SQL Server, Oracle, Firebird (Interbase),
Access) you could put all these queries in a stored procedure (except
Access) and execute that stored procedure passing it the search criteria
from that search form.

Once all queries are executed (or store procedure)

SELECT * FROM <TempTableName> ORDER BY <SortField(s)>

And present that table.
--
Stéphane Richard
"Ada World" Webmaster
http://www.adaworld.com
"Adrian Parker" <no@addy.com> wrote in message
news:X1*******************@news20.bellglobal.com.. .
I have a database of 200+ tables (two tables per school), each with 100 -
4000 records (one record per student). A contract I'm looking at wants to
be able to do a search across all the tables, searching for values a user
inputs via a Search form.

I have a solution, but I don't think it'll work on large scales.

Is there a better bet then querying table 1, finding matching values and
writing those records into an ADO variable, closing that table, then moving on to the next table etc?

That seems a very brute force method to me.

<Ade
--
Adrian Parker. Ordained priest. <ad***********@sympatico.ca>
Want to know the purpose of life? I'd be happy to share it with you...

Jul 17 '05 #2

"Stephane Richard" <st**************@verizon.net> wrote in message
news:Tk*****************@nwrdny01.gnilink.net...
You could do it all in SQL and create a temp table for the results. if all 200 Table have the same structure (which I assume they do here, you'd need a series of (Idealy adding perhaps a SchoolID field to a table and filtering
all records by School ID instead of having a table per school would save you a lot of time for this :-).
Ya, but try convincing the entire Leeds & Grenville schoolboard that they
have to change their existing format :)

SELECT INTO <TempTableName> * FROM <TableName> WHERE <ListOfCriteria>

Depending on Database type (MySQL, SQL Server, Oracle, Firebird (Interbase), Access) you could put all these queries in a stored procedure (except
Access) and execute that stored procedure passing it the search criteria
from that search form.


I am indeed using Access though. Any ideas?
<snip>
Adrian
Jul 17 '05 #3
in a VB loop, execute the first query that I showed in my last message

Select Into <TempTableName> * FROM <TableName> WHERE <Conditions>

Making sure <TempTableName> is the same name for all queries

Once they are all done (which shuold be faster, much faster than using ADO
recordset Objects do insert). (hence right after the loop is done.

Open a recordset Object in dbOpenDynaset mode. with the query

SELECT * from <TempTableName> ORDER BY <Sort order>" and you should be set.

--
Stéphane Richard
"Ada World" Webmaster
http://www.adaworld.com
"Adrian Parker" <no@addy.com> wrote in message
news:r1*******************@news20.bellglobal.com.. .

"Stephane Richard" <st**************@verizon.net> wrote in message
news:Tk*****************@nwrdny01.gnilink.net...
You could do it all in SQL and create a temp table for the results. if all
200 Table have the same structure (which I assume they do here, you'd need a
series of (Idealy adding perhaps a SchoolID field to a table and

filtering all records by School ID instead of having a table per school would save

you
a lot of time for this :-).


Ya, but try convincing the entire Leeds & Grenville schoolboard that they
have to change their existing format :)

SELECT INTO <TempTableName> * FROM <TableName> WHERE <ListOfCriteria>

Depending on Database type (MySQL, SQL Server, Oracle, Firebird

(Interbase),
Access) you could put all these queries in a stored procedure (except
Access) and execute that stored procedure passing it the search criteria
from that search form.


I am indeed using Access though. Any ideas?
<snip>
Adrian

Jul 17 '05 #4
If "Ya, but try..." means that yes, the tables are the same structure, but no,
you can't make a single table out of them (the correct design), then you might
consider a Union query. A Union query requires that each Select statement return
the same fields, in the same order. A sample:

Select StudentName, StudentGrade FROM SchoolATable
UNION
Select StudentName, StudentGrade FROM SchoolBTable
UNION
Select StudentName, StudentGrade FROM SchoolCTable...etc.

In other words, it creates a temporary result set that is essentially the
combined table. You can apply criteria to it as well. I have no idea if
UNION'ing 200 tables is acceptable or not.

----Thought #2

Sometimes you can fake people out and hide the real table structure. If you made
a combined table with a SchoolID field, say call it AllSchools, you can then
create a set of 200 queries, each specifying a specific SchoolID value. If you
name the queries whatever the 200 tables used to be called, no one need be any
the wiser (except you). Stored select queries (or views) are treated the same as
tables by forms, reports, other queries, ADO recordset commands, etc. In fact,
when you open a table "directly", the underlying database engine is just running
the implied query "Select * from TableName" anyway.
"Adrian Parker" <no@addy.com> wrote in message
news:r1*******************@news20.bellglobal.com.. .

"Stephane Richard" <st**************@verizon.net> wrote in message
news:Tk*****************@nwrdny01.gnilink.net...
You could do it all in SQL and create a temp table for the results. if

all
200 Table have the same structure (which I assume they do here, you'd need

a
series of (Idealy adding perhaps a SchoolID field to a table and filtering
all records by School ID instead of having a table per school would save

you
a lot of time for this :-).


Ya, but try convincing the entire Leeds & Grenville schoolboard that they
have to change their existing format :)

SELECT INTO <TempTableName> * FROM <TableName> WHERE <ListOfCriteria>

Depending on Database type (MySQL, SQL Server, Oracle, Firebird

(Interbase),
Access) you could put all these queries in a stored procedure (except
Access) and execute that stored procedure passing it the search criteria
from that search form.


I am indeed using Access though. Any ideas?
<snip>
Adrian

Jul 17 '05 #5

"Stephane Richard" <st**************@verizon.net> wrote in message
news:5k*****************@nwrdny01.gnilink.net...
in a VB loop, execute the first query that I showed in my last message

Select Into <TempTableName> * FROM <TableName> WHERE <Conditions>

Making sure <TempTableName> is the same name for all queries

Once they are all done (which shuold be faster, much faster than using ADO
recordset Objects do insert). (hence right after the loop is done.

Open a recordset Object in dbOpenDynaset mode. with the query

SELECT * from <TempTableName> ORDER BY <Sort order>" and you should be

set.

How slow do you think querying 200+ tables would be, if the average amount
of records was 700?

I'll try as explained. I didn't know that Visual Basic could call SQL
statements without using an ADO object.
Adrian
Jul 17 '05 #6

"Stephane Richard" <st**************@verizon.net> wrote in message
news:5k*****************@nwrdny01.gnilink.net...
in a VB loop, execute the first query that I showed in my last message

Select Into <TempTableName> * FROM <TableName> WHERE <Conditions>

Making sure <TempTableName> is the same name for all queries

Once they are all done (which shuold be faster, much faster than using ADO
recordset Objects do insert). (hence right after the loop is done.

Open a recordset Object in dbOpenDynaset mode. with the query

SELECT * from <TempTableName> ORDER BY <Sort order>" and you should be

set.
Also, how do I get the names of the tables dynamically?

I do not want to write out the names of 200 tables in a config file.

Can I use the usual SHOW TABLES statement?
Adrian
Jul 17 '05 #7

"Steve Gerrard" <no*************@comcast.net> wrote in message
news:5X********************@comcast.com...
If "Ya, but try..." means that yes, the tables are the same structure, but no, you can't make a single table out of them (the correct design), then you might consider a Union query. A Union query requires that each Select statement return the same fields, in the same order. A sample:

Select StudentName, StudentGrade FROM SchoolATable
UNION
Select StudentName, StudentGrade FROM SchoolBTable
UNION
Select StudentName, StudentGrade FROM SchoolCTable...etc.

In other words, it creates a temporary result set that is essentially the
combined table. You can apply criteria to it as well. I have no idea if
UNION'ing 200 tables is acceptable or not.


How do I run this from VB though without using an ADO object?
Adrian
Jul 17 '05 #8

"Adrian Parker" <no@addy.com> skrev i en meddelelse
news:X1*******************@news20.bellglobal.com.. .
I have a database of 200+ tables (two tables per school), each with 100 - 4000 records (one record per student). A contract I'm looking

at wants to

That sounds like a design flaw to me :-/
--
/\ preben nielsen
\/\ pr**@post.tele.dk
Jul 17 '05 #9

"Adrian Parker" <no@addy.com> wrote in message
news:Nn********************@news20.bellglobal.com. ..

"Steve Gerrard" <no*************@comcast.net> wrote in message
news:5X********************@comcast.com...
If "Ya, but try..." means that yes, the tables are the same structure, but

no,
you can't make a single table out of them (the correct design), then you

might
consider a Union query. A Union query requires that each Select statement

return
the same fields, in the same order. A sample:

Select StudentName, StudentGrade FROM SchoolATable
UNION
Select StudentName, StudentGrade FROM SchoolBTable
UNION
Select StudentName, StudentGrade FROM SchoolCTable...etc.

In other words, it creates a temporary result set that is essentially the
combined table. You can apply criteria to it as well. I have no idea if
UNION'ing 200 tables is acceptable or not.


How do I run this from VB though without using an ADO object?
Adrian


Not sure what you mean. ADO is all objects. I think you need at least a
connection and a recordset to do anything.

A union query, such as the one above, can be used in place of a standard select
query as command text or as the the SQL passed to the OpenRecordset method. You
can also construct such a query in Access, which I think you said you were
using. It is in the Query menu of the query designer. Once it is in the Access
database, you can select from it and filter it the same way you would get data
from a table.

Jul 17 '05 #10
Wait a sec. I reread some earlier posts. What Stephane meant about executing
"Select Into" queries, rather than inserting using an object, was that copying
records from one ADO recordset to another would be slower.

To execute a SQL command, you still need to create and open an ADO connection
object. Then you can make calls to conn.Execute(strYourSQLActionText) for
"action queries" (ones that do something). You can also make a new ADO Recordset
object, and do rsMyRecs = conn.Execute(strYourSQLSelectText) for queries that
return records. strYourSQLSelectText could be a union query, for instance.

"Adrian Parker" <no@addy.com> wrote in message
news:Nn********************@news20.bellglobal.com. ..

"Steve Gerrard" <no*************@comcast.net> wrote in message
news:5X********************@comcast.com...
If "Ya, but try..." means that yes, the tables are the same structure, but

no,
you can't make a single table out of them (the correct design), then you

might
consider a Union query. A Union query requires that each Select statement

return
the same fields, in the same order. A sample:

Select StudentName, StudentGrade FROM SchoolATable
UNION
Select StudentName, StudentGrade FROM SchoolBTable
UNION
Select StudentName, StudentGrade FROM SchoolCTable...etc.

In other words, it creates a temporary result set that is essentially the
combined table. You can apply criteria to it as well. I have no idea if
UNION'ing 200 tables is acceptable or not.


How do I run this from VB though without using an ADO object?
Adrian

Jul 17 '05 #11
Shiela Marie
1 New Member
i have read about your discussion. i think i am having the same problem.
I have a single "members" table containing about 65,000 records. accessing it using a windows 98 computer with 64MB RAM as well as some MHz or 1. something GHZ speed is quite slow. Thus, i decided to chop it off into 26 tables (from memberA - memberZ).

The problem is i don't know what to do inorder to make the accessing of the record faster. I tried UNION but it can only access up to 3 tables.

help please.

PS for additional info, i have a command to search the table by memberName or memberID.
Sep 9 '05 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
4124
by: R. Rajesh Jeba Anbiah | last post by:
Q: Is PHP search engine friendly? Q: Will search engine spiders crawl my PHP pages? A: Spiders should crawl anything provided they're accessible. Since, nowadays most of the websites are been developed with PHP, you are not supposed to doubt that. As a proof that PHP pages could be crawled and indexed, refer this Google search
10
39328
by: Anand Pillai | last post by:
To search a word in a group of words, say a paragraph or a web page, would a string search or a regexp search be faster? The string search would of course be, if str.find(substr) != -1: domything() And the regexp search assuming no case restriction would be,
1
8707
by: Les Juby | last post by:
A year or two back I needed a search script to scan thru HTML files on a client site. Usual sorta thing. A quick search turned up a neat script that provided great search results. It was fast, returned the hyperlinked page title, filename, and the body txt (30 preceding and following words) in context with the search word highlighted. ...
5
2957
by: George | last post by:
Hi, Anyone has the background for explaining? I have made a search on my name and I have got a link to another search engine. The link's title was the search phrase for the other search engine (a wicked phrase). Some but not all of the words of that phrase exist in my website. I reported it and they removed the link but did not give...
39
4356
by: Noticedtrends | last post by:
Can inference search-engines narrow-down the number of often irrelevant results, by using specific keywords; for the purpose of discerning emerging social & business trends? For example, if authors of content subconsciously mention the keywords "lately and noticed" within the same brief sentence, the reader may infer "an unintended message"...
28
3129
by: joshc | last post by:
If I have an array of data that I know to be sorted in increasing order, and the array is less than 50 elements, and I want to find the first element greater than a certain value, is a simple linear search the best here(for loop from beginning to end of array)? It seems like some other search algorithm like binary or whatever would be of no...
4
2157
by: BenCoo | last post by:
Hello, In a Binary Search Tree I get the error : Object must be of type String if I run the form only with the "Dim bstLidnummer As New BinarySearchTree" it works fine. Thanks for any help on this, Benny
1
7515
Merlin1857
by: Merlin1857 | last post by:
How to search multiple fields using ASP A major issue for me when I first started writing in VB Script was constructing the ability to search a table using multiple field input from a form and having the sql statement dynamically built according to the input provided by the user. I have used the method described here hundreds of times it is...
0
2432
by: passion | last post by:
"Specialized Search Engines" along with Google Search Capability (2 in 1): http://specialized-search-engines.blogspot.com/ Billions of websites are available on the web and plenty of extremely good search engines are there like Google, Yahoo and Live to name few of them. Though this search engines have extremely efficient, complex and...
0
7321
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7564
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7718
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
5861
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
4876
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3377
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1788
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
941
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
615
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.