|
楼主 |
发表于 2019-2-21 01:04
|
显示全部楼层
提示 至少有一个参数没有被指定值 我检查了N遍,头都晕了
Private Sub Command1_Click()
Dim conn As New ADODB.Connection, rs As New ADODB.Recordset
Dim SQL$, sqlA$, sqlB$, sqlC$, sqlD$, sqlE$, link$, i As Long
'link = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=E:\My Documents\Desktop\bhTool\补货明细.xls;Extended Properties=Excel 12.0"
link = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\My Documents\Desktop\bhTool\补货明细.xls;Extended Properties='Excel 8.0';Persist Security Info=False"
conn.Open link
sqlA = "(select t1.补货仓库,t1.商品分类,t1.商品名称,t1.规格,t1.单位,t1.商品编号,t1.数量,t1.商品备注 from [补货明细$]) t1"
sqlB = "(select t2.仓库,t2.编号,t2.总库存数 as 门店库存,t2.寄存数 as 门店寄存 from [excel 8.0;database=E:\My Documents\Desktop\bhTool\门店库存.xls;].[门店库存$]) t2"
sqlC = "(select * from [excel 8.0;database=E:\My Documents\Desktop\bhTool\仓库库存.xls;].[总库库存$]) t3"
sqlD = "(select * from [excel 8.0;database=E:\My Documents\Desktop\bhTool\上月销售.xls;].[上月销售$]) t4"
sqlE = "(select * from [excel 8.0;database=E:\My Documents\Desktop\bhTool\本月销售.xls;].[本月销售$]) t5"
' sqlA = "(select t1.补货仓库,t1.商品分类,t1.商品名称,t1.规格,t1.单位,t1.商品编号,t1.数量,t1.商品备注 from [补货明细$]) t1"
' sqlB = "(select t2.仓库,t2.编号,t2.总库存数 as 门店库存,t2.寄存数 as 门店寄存 from [excel 8.0;database=E:\My Documents\Desktop\bhTool\门店库存.xls;].[门店库存$]) t2"
' sqlC = "(select t3.仓库,t3.编号,t3.总库存数 as 仓库库存 from [excel 8.0;database=E:\My Documents\Desktop\bhTool\仓库库存.xls;].[总库库存$]) t3"
' sqlD = "(select t4.门店名称,t4.商品编号,t4.实际数量 as 上月销量 from [excel 8.0;database=E:\My Documents\Desktop\bhTool\上月销售.xls;].[上月销售$]) t4"
' sqlE = "(select t5.门店名称,t5.商品编号,t5.实际数量 as 本月销量 from [excel 8.0;database=E:\My Documents\Desktop\bhTool\本月销售.xls;].[本月销售$]) t5"
' sqlA = "(select * from [补货明细$]) t1"
' sqlB = "(select * from [excel 8.0;database=E:\My Documents\Desktop\bhTool\门店库存.xls;].[门店库存$]) t2"
' sqlC = "(select * from [excel 8.0;database=E:\My Documents\Desktop\bhTool\仓库库存.xls;].[总库库存$]) t3"
' sqlD = "(select * from [excel 8.0;database=E:\My Documents\Desktop\bhTool\上月销售.xls;].[上月销售$]) t4"
' sqlE = "(select * from [excel 8.0;database=E:\My Documents\Desktop\bhTool\本月销售.xls;].[本月销售$]) t5"
SQL = "select * from (((" & _
sqlA & " left join " & _
sqlB & " on t2.仓库=t1.补货仓库 and t2.编号= t1.商品编号) left join " & _
sqlC & " on t3.编号=t1.商品编号) left join " & _
sqlD & " on t4.门店名称=t1.补货仓库 and t4.商品编号=t1.商品编号) left join " & _
sqlE & " on t5.门店名称=t1.补货仓库 and t5.商品编号=t1.商品编号"
Debug.Print SQL
If rs.State = adStateOpen Then rs.Close
rs.Open SQL, conn, 1, 3
rs.MoveLast
rs.MoveFirst
Debug.Print rs.RecordCount
Debug.Print rs.Fields.Count
' For i = 0 To rs.Fields.Count - 1
' Debug.Print rs.Fields(i)
' Next
Do Until rs.EOF
Debug.Print rs("补货仓库") & " " & rs("商品编号") & " " & rs("门店库存") & " " & rs("门店寄存")
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
conn.Close
Set conn = Nothing
End Sub
|
|