Dim cmd As new SQLCommand
cmd.cfont-family: 宋体; font-size: 12px;">鲜迪数据库"
For Each dr As DataRow In DataTables("存货档案").DataRows
cmd.CommandText = "Select top 1 余额 Fro m {存货账} Where 商品名称 = '" & dr("存货名称") & "' and 余额 is not null order by [_Identify] desc "
If cmd.CommandText IsNot Nothing
dr("账面数量") = cmd.executescalar
Else
dr("账面数量") = 0
End If
Next