<%
Dim strDayNow = "09-Feb-2019"
Dim strDay3Month = DateAdd("m",-3,strDayNow)
strSQL = "SELECT * FROM orders WHERE ORDER_DATE BETWEEN '"&strDayNow&"' and '"&strDay3Month&"'
%>
Dim strDayNow = "1-Jan-2553"
Dim strDay3Month = DateAdd("m", -3, strDayNow)
sql = "Select sum(b.QTY) as Avg3,b.Stockcode from MOR_SO a inner join MOR_SO_Detail b on a.SOID = b.SOID"
sql = sql & " WHERE a.SODate BETWEEN '" & strDay3Month & "' and '" & strDayNow & "' Group by b.StockCode "
ad = New SqlDataAdapter(sql, Conn)
ad.Fill(ds, "MyData")
Dim DView As DataView
DView = ds.Tables("MyData").DefaultView
For Each drowview In DView
Dim SO_OTY = drowview.Item("Avg3")
Dim SO_StockCode = drowview.Item("Stockcode")
e.Item.Cells(4).Text = SO_OTY.ToString()
Next
Dim strDayNow = "1-Jan-2553"
Dim strDay3Month = DateAdd("m", -3, strDayNow)
sql = "Select sum(b.QTY) as Avg3,b.Stockcode from MOR_SO a inner join MOR_SO_Detail b on a.SOID = b.SOID"
sql = sql & " WHERE a.SODate BETWEEN '" & strDay3Month & "' and '" & strDayNow & "' Group by b.StockCode "
ad = New SqlDataAdapter(sql, Conn)
ad.Fill(ds, "MyData")
Dim DView As DataView
Dim datatoCal() as string เพิ่มบรรทัดนี้
Dim cntRec as integer เพิ่มบรรทัดนี้
DView = ds.Tables("MyData").DefaultView
cntRec = 0 เพิ่มบรรทัดนี้
For Each drowview In DView
Dim SO_OTY = drowview.Item("Avg3")
Dim SO_StockCode = drowview.Item("Stockcode")
datatoCal(cntRec) = drowview.Item("Stockcode") เพิ่มบรรทัดนี้
e.Item.Cells(4).Text = SO_OTY.ToString()
cntRec+=cntRec เพิ่มบรรทัดนี้
Next