'建议增加一个字段:出库数量’
Dim adoCon As ADODB.Connection
Dim rs As ADODB.Recordset
set adoCon = New ADODB.Connection
set rs = New ADODB.Recordset
adoCon.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\db_sjk.mdb;Persist Security Info=False"
adoCon.Open()
Dim strSql As String = "SELECT 商品名称,sum(出库数量),sum(入库单价*出库数量) from tb_in group by 商品名称 order by 商品名称"
rs.Open(strSql, adoCon, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic)
Dim i As Integer
i = 1
Do While Not rs.EOF
mf1.TextMatrix(i, 2) = rs(0).Value
mf1.TextMatrix(i, 3) = rs(2).Value
mf1.TextMatrix(i, 4) = rs(3).Value
rs.MoveNext()
i = i + 1
Loop
rs.Close()
adoCon.Close()
好长时间动vb了,这是在.net下调试的,试试吧
Dim adoCon As ADODB.Connection
Dim rs As ADODB.Recordset
set adoCon = New ADODB.Connection
set rs = New ADODB.Recordset
adoCon.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\db_sjk.mdb;Persist Security Info=False"
adoCon.Open()
Dim strSql As String = "SELECT 商品名称,sum(出库数量),sum(入库单价*出库数量) from tb_in group by 商品名称 order by 商品名称"
rs.Open(strSql, adoCon, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic)
Dim i As Integer
i = 1
Do While Not rs.EOF
mf1.TextMatrix(i, 2) = rs(0).Value
mf1.TextMatrix(i, 3) = rs(2).Value
mf1.TextMatrix(i, 4) = rs(3).Value
rs.MoveNext()
i = i + 1
Loop
rs.Close()
adoCon.Close()
好长时间动vb了,这是在.net下调试的,试试吧