Wrox Programmer Forums
|
BOOK: Expert One-on-One Visual Basic 2005 Database Programming
This is the forum to discuss the Wrox book Expert One-on-One Visual Basic 2005 Database Programming by Roger Jennings; ISBN: 9780764576782
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Expert One-on-One Visual Basic 2005 Database Programming section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 12th, 2006, 07:09 PM
Registered User
 
Join Date: Jan 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Add Joins to DataTable Select Commands

In Chapter 6 pg 222 it steps through adding a join to the select command between the Order Details and Products tables. The commandtext is updated for the join in the SelectCommand, DeleteCommand, InsertCommand, and UpdateCommand after following the steps in the book.

If you used the same 3 tables but you want the join to be between the Orders and Products tables, with the linking table as Order Details in in the middle, the joining process (steps) do not seem to work? The DeleteCommand, InsertCommand, and UpdateCommand code does not update, I assume because of a linking table. How might you recommend achieving this task of showing Orders information in Products.

 
Old February 7th, 2006, 07:46 PM
Wrox Author
 
Join Date: Feb 2006
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Default

If you're looking for a result similar to that from the following Northwind query, presumably with the ProductID constraint parameterized:

SELECT Orders.OrderID, Orders.CustomerID, Products.ProductID,
Products.ProductName, [Order Details].Quantity
FROM Orders INNER JOIN [Order Details] ON Orders.OrderID = [Order Details].OrderID
INNER JOIN Products ON [Order Details].ProductID = Products.ProductID
WHERE Products.ProductID = 51
ORDER BY Orders.OrderID DESC

Which returns something like the following:

11055 HILAA 51 Manjimup Dried Apples 20
11045 BOTTM 51 Manjimup Dried Apples 24
11026 FRANS 51 Manjimup Dried Apples 10
11021 QUICK 51 Manjimup Dried Apples 44
10999 OTTIK 51 Manjimup Dried Apples 15
10995 PERIC 51 Manjimup Dried Apples 20
10977 FOLKO 51 Manjimup Dried Apples 10
10965 OLDWO 51 Manjimup Dried Apples 16
...

The resultset isn't updatable. (Try pasting the query into SSMS or the Express version.) This type of query isn't amenable to drag-and-drop ("codeless") DataGridView or DataGrid generation, but you could pass a selected ProductID value from a Products grid to a dynamic SQL string or a parameterized stored procedure call to populate a grid with Orders data.

--rj





Similar Threads
Thread Thread Starter Forum Replies Last Post
DataTable.Select() method bug jpichler C# 3 October 5th, 2009 12:24 PM
how to add a dataRow[] into a datatable sendtogary VS.NET 2002/2003 0 March 27th, 2006 05:32 AM
Add a Row to a DataTable in a specified location infernokodiak C# 1 January 16th, 2006 05:32 PM
Converting my sql select to use LEFT JOINs elfranko PHP Databases 0 December 1st, 2005 07:01 AM
how to use DataTable.Select Salte C# 2 December 22nd, 2004 04:28 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.