Dim cmd As New SQLCommand
Dim dt As DataTable
DataTables("rdrecords11").datarows.clear
cmd.C
Dim Cols111() As String = {"cInvcode","iquantity"}
Dim Cols222() As String = {"PartNo","Qty"}
cmd.CommandText ="select cInvcode,年,月,sum(iquantity) as iquantity from (Select cInvcode,iquantity,year(dvdate) as 年,month(dvdate) as 月 From {rdrecords11} Where [dvDate] > = '" & e.Form.Controls("Datetimepicker1").Value & "' And [dvDate] < = '" & e.Form.Controls("Datetimepicker2").Value & "') as a group by cInvcode,年,月"
dt = cmd.ExecuteReader()
For Each dr1 As DataRow In dt.DataRows
Dim dr2 As DataRow = DataTables("rdrecords11").AddNew()
For i As Integer = 0 To Cols111.Length -1
dr2(Cols222(i)) = dr1(Cols111(i))
Next
dr2("date") = new Date(dr1("年"),dr1("月"),1)
Next