如何在vb中将access中的一张表中的数据统计后显示在另一张表中 ,vb中用datagrid呈现
表1:IDSKUQUANTITY11321124315544323342545323204134445445535456563523565465462250713表2:统...
表1:
ID SKU QUANTITY
1 1 321
1 2 43
1 5 5443
2 3 34
2 5 45
3 2 320
4 1 34
4 4 5445
5 3 54
5 6 563
5 2 356
5 4 654
6 2 250
7 1 3
表2:统计出每个订单的所需货物总数和涉及多少种货物,以及每种货物的的总量和涉及的订单数
Private myconn As New ADODB.Connection
Private Sub Form_Load()
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\db1.mdb;Persist Security Info=False"
Adodc1.CommandType = adCmdTable
……
Set myconn = New ADODB.Connection
myconn.Open
myconn.Execute "insert into EIQ分析(ID) select * from [order] group by ID" & _
"insert into EIQ分析(数量) select sum (QUANTITY) from [order] where [order].ID =EIQ分析.ID" & _
"insert into EIQ分析(品项数)select count(SKU) from [order] where where [order].ID =EIQ分析.ID" & _
"insert into EIQ分析(SKU) select * from [order] group by SKU" & _
"insert into EIQ分析(总量) select sum (QUANTITY) from [order] where [order].SKU =EIQ分析.SKU" & _
"insert into EIQ分析(需求次数)select count(ID) from [order] where where [order].SKU =EIQ分析.SKU"
myconn.Close
DataGrid1.Refresh
DataGrid2.Refresh
End Sub
刚学这,基本不懂,帮忙看下修改下 展开
ID SKU QUANTITY
1 1 321
1 2 43
1 5 5443
2 3 34
2 5 45
3 2 320
4 1 34
4 4 5445
5 3 54
5 6 563
5 2 356
5 4 654
6 2 250
7 1 3
表2:统计出每个订单的所需货物总数和涉及多少种货物,以及每种货物的的总量和涉及的订单数
Private myconn As New ADODB.Connection
Private Sub Form_Load()
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\db1.mdb;Persist Security Info=False"
Adodc1.CommandType = adCmdTable
……
Set myconn = New ADODB.Connection
myconn.Open
myconn.Execute "insert into EIQ分析(ID) select * from [order] group by ID" & _
"insert into EIQ分析(数量) select sum (QUANTITY) from [order] where [order].ID =EIQ分析.ID" & _
"insert into EIQ分析(品项数)select count(SKU) from [order] where where [order].ID =EIQ分析.ID" & _
"insert into EIQ分析(SKU) select * from [order] group by SKU" & _
"insert into EIQ分析(总量) select sum (QUANTITY) from [order] where [order].SKU =EIQ分析.SKU" & _
"insert into EIQ分析(需求次数)select count(ID) from [order] where where [order].SKU =EIQ分析.SKU"
myconn.Close
DataGrid1.Refresh
DataGrid2.Refresh
End Sub
刚学这,基本不懂,帮忙看下修改下 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询