question

kumar23 avatar image
kumar23 asked

How to use alias column value in a for each loop

Hi can any one help me to give me a suggestion how to get alias column value from i'm trying to use a for each loop in vb.net using a datatable. My code is actually shown below If CInt(RowItem.Item("TOTALLINENO")) 500 Then For c As Integer = 0 To tblRawTesterShutdown.Columns.Count - 1 If CInt(tblRawTesterShutdown.Rows(c)(10)("Percentage")); Max Then **Max = CInt(tblRawTesterShutdown.Rows(c)(10)("Percentage"))** End If Next **Max = Max - Convert.ToInt32(tblRawTesterShutdown.Rows(tblRawTesterShutdown.Rows.Count - 1))** Else Return False End If 'End here I have do it in vs 2005. The percentage is a sql server query. the query is shown below SELECT t1.LINE_NO, t1.E_FIELD, t1.F_FIELD, t1.G_FIELD, t1.FAMILY, t1.HSA_STATUS,t1.CACHE_FAMILY, SUM(t1.TOTAL) AS CountOfLineNo, t2.TotalOfLineNo, **convert(decimal(18,3),(convert(decimal(8,1),SUM(t1.TOTAL)) * 100 / t2.TotalOfLineNo )/100)AS Percentage** FROM( SELECT LINE_NO, E_FIELD,F_FIELD,G_FIELD,HSA_STATUS,FAMILY,CACHE_FAMILY, Count(LINE_NO) as Total FROM TX_HSA_SUMM WITH(NOLOCK) WHERE MT_TIMESTAMP2 BETWEEN ('2013-04-03 14:28:00.000') AND ('2013-04-03 14:28:00.000') AND E_FIELD!='00000' AND F_FIELD!='00000' AND G_FIELD!='00000' -- added new line GROUP BY LINE_NO,E_FIELD,F_FIELD,G_FIELD,HSA_STATUS,FAMILY,CACHE_FAMILY ) AS t1 LEFT JOIN ( SELECT LINE_NO, COUNT(LINE_NO) AS TotalOfLineNo FROM TX_HSA_SUMM WITH(NOLOCK) WHERE MT_TIMESTAMP2 BETWEEN ('2013-04-03 14:28:00.000') AND ('2013-04-03 14:28:00.000') GROUP BY LINE_NO ) AS t2 ON t1.LINE_NO = t2.LINE_NO GROUP BY t1.LINE_NO, t1.E_FIELD, t1.F_FIELD, t1.G_FIELD, t1.HSA_STATUS, t1.FAMILY, t1.CACHE_FAMILY, t1.Total,t2.TotalOfLineNo HAVING t2.TotalOfLineNo > '500' and t1.line_no='64072m' and hsa_status='r' ORDER BY t1.E_FIELD, t1.F_FIELD, t1.G_FIELD, t2.TotalOfLineNo,t1.Total,t1.HSA_STATUS, t1.LINE_NO, t1.FAMILY, t1.CACHE_FAMILY The bold Percentage value from sql server should be used in the vb.net for each loop actually. I'm using vs 2005 ans sql server 2000. Thanks in advance
sql-server-2000vb2005
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

0 Answers

·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.