Question about a dataset

  • Thread starter Thread starter Simon Harvey
  • Start date Start date
S

Simon Harvey

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
 
Hi Simon,

Simon Harvey said:
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.

Generally speaking, ADO.NET (Fill method actually) can read multiple
results from a command.
Now, the question is, if the provider/database supports multiple datasets in
one command.
Sql Server does, but I think that jet/access doesn't support it.
 
Simon Harvey said:
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).
 
Back
Top