Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 Row Problem

Author  Topic 

OBINNA_EKE
Posting Yak Master

234 Posts

Posted - 2006-09-21 : 06:25:32
I am displaying record sets like this

While (NOT rsEquipments.EOF)
SQL = SQL & "<tr bgcolor=''> "
SQL = SQL & "<td class='ColTitles'>"&k&" </td>"
SQL = SQL & "<td class='ColTitles'>"&rsEquipments.Fields.Item("RMANo").value&" </td>"
SQL = SQL & "<td class='ColTitles'>"&UCase(rsEquipments.Fields.Item("SerialNo").Value)&" </td>"
SQL = SQL & "<td class='ColTitles'>"&rsEquipments.Fields.Item("QTy").value&" </td>"
SQL = SQL & "<td class='ColTitles'>"&rsEquipments.Fields.Item("Model").value&" </td>"
SQL = SQL & "<td class='ColTitles'>"&ChangeTypeText(rsEquipments.Fields.Item("Type").value)&" </td>"
SQL = SQL & "</tr>"

k = k + 1
SaveLog rsEquipments.Fields.Item("RMANo").value , rsEquipments.Fields.Item("SubCustomerContactID").value
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
'Response.Write("<br>RMA is "&rsEquipments.Fields.Item("RMANo").value)
rsEquipments.MoveNext()
Wend

This is the output

# RMA No: Serial No: Qty Model Type
1 13751 2PNC00534E9S9VC 1 TS Clear SRM2000 Batch
2 8725 2PNC00534E9S9XP 1 TS Clear SRM2000 Batch

The Output I want now is

# QTY Serial No: Model
1 2 (13751-2PNC00534E9S9VC)(8725-2PNC00534E9S9XP)Model

As you can see that the two equipment has got the same model there it should be on the same row and qty calculated as well

Thanks










If it is that easy, everybody will be doing it

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-09-21 : 06:53:42
I think we you have teached you before how to concat rows.
Feel free to search this site for row concatening functions.


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

snSQL
Master Smack Fu Yak Hacker

1837 Posts

Posted - 2006-09-21 : 16:37:46
Something like this should work


Dim LastModel, SerialNumber, Qty
LastModel = -1
While (NOT rsEquipments.EOF)
If LastModel = rsEquipments.Fields.Item("Model").value Then
SerialNumber = SerialNumber & "(" & UCase(rsEquipments.Fields.Item("SerialNo").Value) & ")"
Qty = Qty + rsEquipments.Fields.Item("Qty").value
Else
If LastModel <> -1 Then
SQL = SQL & "<tr bgcolor=''> "
SQL = SQL & "<td class='ColTitles'>"&k&" </td>"
SQL = SQL & "<td class='ColTitles'>"&Qty&" </td>"
SQL = SQL & "<td class='ColTitles'>"&SerialNumber&" </td>"
SQL = SQL & "<td class='ColTitles'>"&LastModel&" </td>"
SQL = SQL & "</tr>"
End If
SerialNumber = "(" & UCase(rsEquipments.Fields.Item("SerialNo").Value) & ")"
Qty = rsEquipments.Fields.Item("Qty").value
LastModel = rsEquipments.Fields.Item("Model").value
k = k + 1
End If

SaveLog rsEquipments.Fields.Item("RMANo").value , rsEquipments.Fields.Item("SubCustomerContactID").value
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
'Response.Write("<br>RMA is "&rsEquipments.Fields.Item("RMANo").value)
rsEquipments.MoveNext()
Wend
Go to Top of Page
   

- Advertisement -