"Simon Harvey" <sh856531@microsofts_free_email_service.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi everyone,
I was wondering if it is possible, to use SQL to return more than one
table at a time into a dataset. I only know the basics of SQL and so I'm not
sure if I'm just asking a stupid question. But, I'm not proud! :-)
I'm using Ado.net and I'm wanting to load a DataSet object with several
independent tables. (For those who arent ADO.net programmers, a DataSet
can hold multiple tables and the relationships and contraints attached to
them. - Sort of like a mini-database as I understand it)
My question is - using SQL, will I have to execute several statements and
load the dataset manually, or is there some magic SQL command that I can
use to get more than one table back at once and magiacally into the dataset?
I'm using an access database so I can't use any stored procedures as I
understand it. Don't know of that makes any difference though.
Your advice as always is greatly appreciated.
Thanks
Simon
If you want the entire content of several tables independently, you're best
off (IMHO) using multiple queries to get one table at a time (e.g. SELECT *
FROM tablename). A SQL query can be written to retrieve data from multiple
tables, using the relationships between the tables in question to control
the results, but you have to understand both the design of the related
tables in question and SQL itself to do it successfully. A multiple table
query will return the requested data, but the data will be in a single
"table" in the dataset.
If you're going to pursue database application development, you really owe
it to yourself to learn SQL and relational theory. It'll help a lot in the
long run.
Here's one place you could start
http://www.sqlcourse.com/
Another great tool for learning is Access. If you have Access, you can use
it to design tables, set up relationships and, write and debug queries
(starting with QBE and then observing the generated SQL).
--
Peter [MVP Academic]