|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Creating Strongly Typed Data SetHi,
I created a strongly typed data set that contains two tables (Orders and OrdersDetails). The tables have a parent/child relationship. How can I populate both tables based on values returned by a stored procedure in such a way so that the OrderDetails table contains only data for orders that exist in Orders table (i.e. preserving the parent/child relationship)? I'm usng SQL 2000 and .NET 2.0 Thank you. SELECT * FROM Orders
WHERE X = 'y' SELECT * FROM OrderDetails od JOIN Orders o ON od.OrderID = o.OrderID WHERE o.X = 'y' -- Show quoteGregory A. Beamer ************************************************* Think Outside the Box! ************************************************* "Vi" <V*@discussions.microsoft.com> wrote in message news:E22F9205-B039-448D-AD9D-D42556D3A3DA@microsoft.com... > Hi, > I created a strongly typed data set that contains two tables (Orders and > OrdersDetails). The tables have a parent/child relationship. > > How can I populate both tables based on values returned by a stored > procedure in such a way so that the OrderDetails table contains only data > for > orders that exist in Orders table (i.e. preserving the parent/child > relationship)? > > I'm usng SQL 2000 and .NET 2.0 > > Thank you. Gregory,
But I was refering to how can I populate the tables from the dataset. Thanks Show quote "Cowboy (Gregory A. Beamer)" wrote: > SELECT * FROM Orders > WHERE X = 'y' > > SELECT * FROM OrderDetails od > JOIN Orders o > ON od.OrderID = o.OrderID > WHERE o.X = 'y' > > -- > Gregory A. Beamer > > ************************************************* > Think Outside the Box! > ************************************************* > "Vi" <V*@discussions.microsoft.com> wrote in message > news:E22F9205-B039-448D-AD9D-D42556D3A3DA@microsoft.com... > > Hi, > > I created a strongly typed data set that contains two tables (Orders and > > OrdersDetails). The tables have a parent/child relationship. > > > > How can I populate both tables based on values returned by a stored > > procedure in such a way so that the OrderDetails table contains only data > > for > > orders that exist in Orders table (i.e. preserving the parent/child > > relationship)? > > > > I'm usng SQL 2000 and .NET 2.0 > > > > Thank you. > > > I don't want to sound like a marketing guy, but this is the exact same
problem that I had. It was such a PITA, that I built a tool to do this for me, and now my company is selling it (free to try, and under $100 to buy). It's called the DataSet Toolkit, and it has a class called the MultiTableDataAdapter which does fills and updates of multiple tables in a DataSet. One feature is that it allows you to fill multiple tables using the same WHERE constraint. With this framework, you would create an instance of MultiTableAdapter, and call the following: (Assume your DataSet has two tables: Orders and OrderDetails) multiTableAdapter.Fill(dataSet.OrderDetails, new ValueWhereConstraint(dataSet.Orders.XColumn, "y"); That single line of code will fill the OrderDetails table and the Orders table, using basically the same SQL statements that Cowboy specified. I use it everyday, and it's simplified my programming a lot. Try this out, and let me know what you think. http://www.hydrussoftware.com John B. http://johnsbraindump.blogspot.com |
|||||||||||||||||||||||