“物流表”中的“实际数量”列改变后,会自动修改库存中的相应物料的“数量”,使用的是ACCESS外部数据源。问题是:每次在物流表中新增行后,第一次执行up date语句时会报错,“标准表达式中数据类型不匹配”;我看了下表的列类型都是“单精度小数”,关掉报错后再修改当前行的“实际数量”列,就不会报错了,库存数量也会改变了,请教各位,这是为什么呢?
Dim cmd2 As New SQLCommand
Dim dt2 As DataTable
cmd2.C
cmd2.CommandText = "SELECT * F rom {Store}"
dt2 = cmd2.ExecuteReader()
select case e.DataCol.Name
Case "实际数量"
e.DataRow("出入库时间") = Date.today()
If e.NewValue IsNot Nothing Then
Dim dr As DataRow
dr = dt2.Find("[物料编码] = '" & e.DataRow("物料编码") & "'")
Select Case e.DataRow("出入库方向")
Case "入库"
If dr IsNot Nothing Then
cmd.CommandText = "Up date {Store} Set [数量] = [数量] + '" & e.NewValue & "' - '" & e.OldValue & "' Where [物料编码]= '" & e.DataRow("物料编码") & "'"
cmd.ExecuteNonQuery()
End If
If dr Is Nothing Then
Dim dr1 As DataRow = DataTables("Store").AddNew()
dr1("物料编码") = e.DataRow("物料编码")
dr1("属性") = e.DataRow("类别")
dr1("名称") = e.DataRow("名称")
dr1("图号") = e.DataRow("型号")
dr1("单位") = e.DataRow("单位")
dr1("数量") = e.NewValue
dr1("库存下限") = 0
End If
Case "出库"
If dr Is Nothing Then
MessageBox.Show("库存中无此编号的物料,请确认编号再领取!")
Return
End If
If dr IsNot Nothing Then
If dr("数量") < e.NewValue - e.OldValue Then
messagebox.Show("库存不足,请修改!","提示")
e.cancel = True
End If
If dr("数量") >= e.NewValue - e.OldValue Then
cmd.CommandText = "Up date {Store} Set [数量] = [数量] - '" & e.NewValue & "' + '" & e.OldValue & "' Where [物料编码]= '" & e.DataRow("物料编码") & "'"
cmd.ExecuteNonQuery()
End If
End If
End Select
DataTables("Store").save()
end select