473,434 Members | 1,430 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,434 software developers and data experts.

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 3777
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
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
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...
10
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:...
1
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,...
5
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...
39
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...
28
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...
4
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...
1
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...
0
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.