DataSet Question

  • Thread starter Thread starter Frank Oquendo
  • Start date Start date
F

Frank Oquendo

Let's say I have a query that looks like this:

SELECT Orders.*, Status.NAME
FROM Orders, Status
WHERE Orders.UserId = @UserID
AND Orders.StatusId = Status.StatusId

When I use that populate a DataSet via a DataAdapter, do I get two new
tables or one? What I want is a single table that is the amalgam of
both. Is this possible?

--
There are 10 kinds of people. Those who understand binary and those who
don't.

http://code.acadx.com
(Pull the pin to reply)
 
I suggest listing all fields you want instead of the asterisk
notation. Helps to figure out what is going on later. Also, the use of
@UserID, unless you are looking at writing a stored procedure seems
out of place. I assume you will be passing the ID that want into the
SQL text somehow and this is how you are showing it in the newsgroup.
If so, continue. The code you provide will give you what you want, but
there are other, more succinct ways of writing the statement if you
are using SQL Server / Oracle, etc.
 
Frank,

You should really re-write the SQL statement as:

SELECT Orders.*, Status.NAME
FROM Orders
INNER JOIN Status ON Orders.StatusId = Status.StatusId
WHERE Orders.UserId = @UserID

This will get you one table - I think the other will get you two - but don't
quote me on it. Also, depending on your database structure you may not want
to use an inner join. This is really mroe of a question for a SQL user
group, not a C# group.

Matt
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top