|
楼主 |
发表于 2018-3-13 09:10
|
显示全部楼层
Private Sub Form_Load()
Dim s$, u$, p$, d$, sql$, dd$
Set cn = CreateObject("adodb.connection")
Set rs = CreateObject("adodb.recordset")
'On Error GoTo errconn
s = "192.168.180.5": u = "sa": p = "123": d = "AIS20101124094726": dd = Me.[Text7]
cn.Open "driver=sql server;server=" & s & ";uid=" & u & ";pwd=" & p & ";database=" & d
sql = "select arrivaldate as 到达时间," _
& "t_icitem.fname as 物料," _
& "t_Supplier.fname as 供应商," _
& "POOrder.FHeadSelfP0237 as 产地," _
& "POOrder.fbillno as 订单号," _
& "POOrder.FHeadSelfP0244 as 订货指标," _
& "isnull(POInStock.fbillno,'') as 收料通知单号," _
& "isnull(POInStockEntry.FEntrySelfP0341,'') as 火车号船号," _
& "carno as 汽车号," _
& "floor(isnull(PreNetWeight,0)) as 预报重量," _
& "isnull(GrossDate,0) as 初次称重时间," _
& "floor(isnull(GrossWeight,0)) as 初重," _
& "isnull(EmptyDate,0) as 二次称重时间," _
& "floor(isnull(EmptyWeight,0)) as 末重," _
& "floor(isnull(NetWeight, 0)) As 净重" _
& " from t_zg_weight" _
& " left join t_icitem on t_icitem.fitemid=t_zg_weight.itemid" _
& " left join POOrder on POOrder.finterid=t_zg_weight.poid" _
& " left join t_Supplier on t_Supplier.fitemid=POOrder.fsupplyid" _
& " left join POInStock on POInStock.finterid=t_zg_weight.POStockid" _
& " left join POInStockEntry on POInStockEntry.finterid=POInStock.finterid" _
& " where poid Is Not Null" _
& " and convert(varchar(100),arrivaldate,111) ='" & dd & "'"
Set rs = (cn.Execute(sql))
If rs.RecordCount > 0 Then
Do Until rs.EOF
sql = "insert into T_到厂原料(到达时间,物料,供应商,产地,订单号,订货指标, 收料通知单号,火车号船号,汽车号,预报重量,初次称重时间,初重,末次称重时间,末重,净重)" _
& "values('" & rs(0) & "','" & rs(1) & "','" & rs(2) & "','" & rs(3) & "'," & rs(4) & ",'" & rs(5) & "'," & rs(6) & ",'" & rs(7) & "','" & rs(8) & "'," _
& rs(9) & ",'" & rs(10) & "'," & rs(11) & ",'" & rs(12) & "'," & rs(13) & "," & rs(14)
Loop
End If
cn.Close
Set cn = Nothing
Set rs = Nothing
Exit Sub
'errconn:
'MsgBox Err.Description
'Err.Clear
End Sub
|
|