Question Searching Multiple Databases

danarchy

Member
Joined
Oct 19, 2010
Messages
9
Programming Experience
1-3
Hello All,

I hope someone can help; Its a very basic question really.

I have several tables in one database, which i would like to search. I have googled - with no results!

At the moment, im searching one table with the usual "Select * from tbl where id = txtBox" blah....

But, i would love to know how to select all tables to search.

I am using bindingsource.find(..) at the moment, but would this cut it with multiple tables?

Thanks in advance!

Dan
 
There's no SQL query that will inherently query every table. If you want to query multiple tables then you need to execute multiple queries. It is possible to use a loop of some sort, to insert a different table name each iteration.

BindingSource.Find has nothing specific to do with database tables. It will search the data that's bound to it. That might be data from one database table, only part of a table or multiple tables. It all depends on how you've populated it.

Having said all that, it does seem rather odd to want to search all tables in a database for a single value. Surely you're looking for specific data when you query.
 
Thanks for your response so quickly.

Basically the application is an address book split into
Several categories. I want the end user to be able to search all categories
Rather than a specific one, this means searching all tables in a database..

Thanks for your help
 
What sort of categories are we talking about? On the surface it sounds like you only need two tables. One for the categories and then one for the contacts that has a CategoryID column to specify the category of that contact.
 
Categories are types of trade for e.g. Builder, Plumber etc

I had thought about using Two tables and creating relationships between the Category and person via CategoryID - but this is the first time ive really set about using
VB.NET and OLEDB, so i couldnt find any relating information about displaying tables with relationships in DGV...

So what ive done is probably a novice mistake and created a new table for each category..

Thanks
 
Yeah, you definitely should have gone with the first idea. As far as displaying the data in the a grid, you can only display the result of one query in one grid. If you want data from two tables then you must either use a join to combine them into one result set to display in one grid or else use two grids. You can check this out for an example of using two grids in a master/detail relationship:

Master/Detail (Parent/Child) Data-binding
 
Back
Top