|
zzsql
|
 |
« Reply #1 on: September 05, 2008, 11:37:19 AM » |
|
(to search for customers. DataView underneath with customer info. DDL specifies who is shown. Under that, detailsView showing total orders for that user.
1. Drag and drop 2 SqlDataSource(s). Name something intuitive 2. Configure data sources First! - Click little arrorw, configure data source. - select proper database - select "Customers" table and click CustomerID, and CompanyName - Order by comapny name (if desired) - Must select a primary key to do inserts. - Test, finish. - Go back into data source, go to "Specify" and add a +', '+ between the fields to concatenate. 3. Add a DDL to the top Data Source. - Configure data source, should get a 3-drop-down menu, select the proper data source and fields. 4. Do a count of customer's orders. - Configure second data source. - Select query builder and select "Customers" and "Orders". - See screen capture called query-builder-orders-customers-count.jpg - R-click in the white-area next to the tables, select "Group by". - egads. - drop data list, select the data source, then edit templates. - He really sped through the rest of this but basically, here are the steps: - drop 2 data sources, a DDL and a DetailsView and a Data List. - See the image above.
Resulting query is this: SELECT Customers.CustomerID, Customers.CompanyName, Customers.ContactName, Customers.City, Customers.Country, Customers.Phone, COUNT(Orders.OrderID) AS [Total Orders] FROM Customers INNER JOIN Orders ON Customers.CustomerID = Orders.CustomerID GROUP BY Customers.CustomerID, Customers.CompanyName, Customers.ContactName, Customers.City, Customers.Country, Customers.Phone HAVING (Customers.CustomerID = @CustomerID) ORDER BY Customers.CompanyName
|