Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I looked at the article from the ASP Kick Start "Displaying Rows Grouped by Category", but I am new to .net and can't make the connection for my duplicates in a datagrid. When I add a template column, the code is different than is demostrated in the example.

 

I am using a stored procedure to select Customers; Customers, Phone numbers and PhoneTypes(fax, Cell, Office) are stored in separate tables. I DON'T want the data displayed in a list, it needs to be displayed in a row. EX:

 

Customer Fax_Number Cell_Number Office_Number

Cust1 111-111-1111 222-222-2222 333-333-3333

 

As it is set up now when I run the search for customer I get

 

Customer Phontype Phone Number

Cust1 fax 111-111-1111

Cust1 Office 222-222-2222

Cust1 Cell 333-333-3333

Posted

SELECT

Customers.Name,

Fax.Number,

Cell.Number,

Office.Number

FROM Customers INNER JOIN FAX ON Customers.CustomerID =

Fax.CustomerID INNER JOIN Cell ON Customers.CustomeriD =

Cell.CustomerID Inner JOIN Office ON Customers.CustomerID = Office.CustomerID

 

Or something like that...

Posted

My SQL statement

 

My select statement is

 

Select Customer from Customers As C

Join CustomerPhone As CP on C.CustID = CP.Cust ID

Join Phone AS P on CP.CustID = P.CustID

Join PhoneTypes As PT on P.PhoneTypeID = PT.PhoneTypeID

Where

CustID = @CustID

 

This will select the customer from the customer table, the numbers

from the PhoneNumbers table and the type of number (fax, Business, Cell) from the PhoneTypes table.

Posted

Try joining the Phone table 3 times onto the Customer table, pick the appropriate join depending on if you know that number will exist for each customer. Untested exampe..

 

SELECT

Customer.Name,

Phone1.Number As OFFICE,

Phone2.Number As CELL

FROM Customers INNER JOIN Phone Phone1 ON

Customers.CustID = Phone1.CustID INNER JOIN Phone Phone2 ON Customers.CustID = Phone2.CustID

WHERE

Phone1.PhoneTYpe = 'OFFICE'

AND

Phone2.PhoneType = 'CELL'

 

 

Not sure if that will work without playing around with it some more, but you can give it a try.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...