想直接调用原数据库的GUID字段作为唯一性判断,但是加载不进来,报错,求助。。。
此主题相关图片如下:qq截图20171014193252.png
Dim cmd As New SQLCommand
Dim dt As DataTable
Dim sCols() As String = {"ID","备注","公司品号","公司品名", "公司材质", "公司规格", "公司图号","单据日期","供应类型", "项目单位","客户型号", "客户品名", "客户单号","销售单号","订单数量","客户材质"}
Dim dCols() As String = {"ID","备注","公司品号","公司品名", "公司材质", "公司规格", "公司图号","单据日期","供应类型", "项目单位","客户型号", "客户品名", "客户单号","销售单号","订单数量","客户材质"}
cmd.C
cmd.CommandText = "Se/ect {SALES_DELIVERY}.[DOC_NO] As [预备发货单号],{SALES_ORDER_DOC_D}.REMARK As [备注],[ITEM_CODE] As [公司品号],[ITEM_NAME] As [公司品名],SHORTCUT As [公司材质],{ITEM}.[ITEM_SPECIFICATION] As [公司规格],[DRAWING_NO] As [公司图号],CONVERT(varchar(16),{SALES_DELIVERY}.[DOC_DATE], 23) As [单据日期],{SALES_ORDER_DOC_D}.UDF021 As [供应类型],{SALES_ORDER_DOC_D}.UDF024 As [项目单位],{SALES_ORDER_DOC_D}.UDF025 As [客户型号],{SALES_ORDER_DOC_D}.UDF026 As [客户品名],[CUSTOMER_ORDER_NO] As [客户单号],{SALES_ORDER_DOC}.[DOC_NO] As [销售单号],{SALES_ORDER_DOC_D}.UDF022 As [客户材质],{SALES_ORDER_DOC_D}.[BUSINESS_QTY] As [订单数量],{SALES_DELIVERY_D}.SequenceNumber As [序号],{SALES_ORDER_DOC_D}.[SALES_ORDER_DOC_D_ID] As [ID] From (((({SALES_ORDER_DOC_D} Left JOIN {SALES_ORDER_DOC} ON {SALES_ORDER_DOC}.[SALES_ORDER_DOC_ID] = {SALES_ORDER_DOC_D}.[SALES_ORDER_DOC_ID]) Left JOIN {SALES_ORDER_DOC_SD} ON {SALES_ORDER_DOC_SD}.[SALES_ORDER_DOC_D_ID] = {SALES_ORDER_DOC_D}.[SALES_ORDER_DOC_D_ID]) Left JOIN {SALES_DELIVERY_D} ON {SALES_DELIVERY_D}.[REFERENCE_SOURCE_ID_ROid] = {SALES_ORDER_DOC_SD}.[SALES_ORDER_DOC_SD_ID]) Left JOIN {SALES_DELIVERY} ON {SALES_DELIVERY}.[SALES_DELIVERY_ID] = {SALES_DELIVERY_D}.[SALES_DELIVERY_ID]) Inner JOIN {ITEM} ON {ITEM}.[ITEM_BUSINESS_ID] = {SALES_ORDER_DOC_D}.[ITEM_ID]"
dt = cmd.ExecuteReader()
For Each dr As DataRow In dt.DataRows
Dim t As DataRow= DataTables("销售订单测试").Find("[ID] = \'" & dr(sCols(0)) & "\'")
If t Is Nothing Then \'如果不存在同编号的订单
t = DataTables("销售订单测试").AddNew()
For i As Integer =0 To sCols.Length -1
t(dCols(i)) = dr(sCols(i))
Next
End If
Next