473,322 Members | 1,671 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,322 software developers and data experts.

Populating a Strong Typed Multi Table DataSet


C#

I have a DataSet defined in my project that consists of one main table and 3
child tables. I have a SQL statement that can retrieve all the information
for this structure, but how do I populate my dataset in one hit using a
DataAdapter??

I tried to do something liket his:
daRequest.Fill(ResultDataSet.WorkRequest);
daRequest.Fill(ResultDataSet.WorkRequestAction);
daRequest.Fill(ResultDataSet.WorkRequestEffect);
daRequest.Fill(ResultDataSet.WorkRequestNote);
daRequest.Fill(ResultDataSet.Job);

but it fails when it hits the second one as there is not data for that table
for the particular WorkRequest I am dealing with.

My SQL statement looks like this:

SELECT *
FROM WorkRequest LEFT OUTER JOIN
WorkRequestAction ON WorkRequest.WorkRequestObj =
WorkRequestAction.WorkRequestObj LEFT OUTER JOIN
WorkRequestEffect ON WorkRequest.WorkRequestObj =
WorkRequestEffect.WorkRequestObj LEFT OUTER JOIN WorkRequestNote ON
WorkRequest.WorkRequestObj = WorkRequestNote.WorkRequestObj LEFT OUTER JOIN
Job ON WorkRequest.WorkRequestObj = Job.WorkRequestObj
WHERE WorkRequest.WorkRequestObj = " + WorkRequestObj
Am I approaching this from the right way, or cant you do this kind of thing
with a DataAdapter?

Thanks

Steve
Nov 1 '05 #1
1 2020
Hi,

"Steve" <St***@discussions.microsoft.com> wrote in message
news:77**********************************@microsof t.com...

C#

I have a DataSet defined in my project that consists of one main table and
3
child tables. I have a SQL statement that can retrieve all the
information
for this structure, but how do I populate my dataset in one hit using a
DataAdapter??

I tried to do something liket his:
daRequest.Fill(ResultDataSet.WorkRequest);
daRequest.Fill(ResultDataSet.WorkRequestAction);
daRequest.Fill(ResultDataSet.WorkRequestEffect);
daRequest.Fill(ResultDataSet.WorkRequestNote);
daRequest.Fill(ResultDataSet.Job);

but it fails when it hits the second one as there is not data for that
table
for the particular WorkRequest I am dealing with.

My SQL statement looks like this:

SELECT *
FROM WorkRequest LEFT OUTER JOIN
WorkRequestAction ON WorkRequest.WorkRequestObj =
WorkRequestAction.WorkRequestObj LEFT OUTER JOIN
WorkRequestEffect ON WorkRequest.WorkRequestObj =
WorkRequestEffect.WorkRequestObj LEFT OUTER JOIN WorkRequestNote ON
WorkRequest.WorkRequestObj = WorkRequestNote.WorkRequestObj LEFT OUTER
JOIN
Job ON WorkRequest.WorkRequestObj = Job.WorkRequestObj
WHERE WorkRequest.WorkRequestObj = " + WorkRequestObj
Am I approaching this from the right way, or cant you do this kind of
thing
with a DataAdapter?
No you can't do it like this you need a seperate DataAdapter or at least a
seperate query for each DataTable. Or you would need to have a stored
procedure or batch query that returns multiple tables, but joins won't work
to fill related tables....

HTH,
Greetings

Thanks

Steve

Nov 1 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Drew | last post by:
I have a db table like the following, UID, int auto-increment RegNo Person Relation YearsKnown Now here is some sample data from this table,
3
by: paul.phillips | last post by:
Hi I have the following table (*=Primary Key): tblNews: fldID (Indentity) fldSite int * fldPageID int * fldSection int * fldContent
3
by: Chris Thunell | last post by:
I have 2 forms, on 1 form i use the wizards to create a strong typed dataset with tables from an SQL database... and from that i can do stuff like: me.daEmployee.fill(me.dataset11.tblEmployee) ...
3
by: Steve Amey | last post by:
Hi all I have created a strong DataSet using Visual Studio. I have been in to the DataSet's vb file to have a look at the code and see if I can add things to it. What I'm after is to create a...
3
by: Freeon | last post by:
Hi, I am looking for a way to sort a strong typed dataset. It would seem the most straightforward way is to use a dataview. The only problem is when I use the dataview I seem to loose the strong...
1
by: Steve | last post by:
C# I have a DataSet defined in my project that consists of one main table and 3 child tables. I have a SQL statement that can retrieve all the information for this structure, but how do I...
3
by: sck10 | last post by:
Hello, I am creating a form for users to enter information about a lab and the members of the lab. I have one form (FormView) that they use to enter information about that lab. The keyvalue is...
6
by: Wilfried Mestdagh | last post by:
Hi, I have done following: Add new item - Dataset, then add DataTable, and add a few fields (VS2005) because this seems the only way to let a Crystalreport recognize a datatable in the project....
21
by: Peter Bradley | last post by:
Hi all, This post is sort of tangentially related to my earlier posts on configuration files for DLLs. Does anyone know how to create typed DataSets using VS2005's new DataSet designer, but...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.