再个例子 更清晰
Dim cmd As new SQLCommand
cmd.C
Dim dt As DataTable
cmd.CommandText = "Se lect * From {orderItems} Where [_Identify] Is Null"
dt = cmd.ExecuteReader(True) '记得将参数设置为True
Dim dr As DataRow = dt.AddNew()
dr("o_id") = "30385065"
dr("oi_id") = "29348516"
Dim f As String = "o_id = '" & dr("o_id") & "' And oi_id = '" & dr("oi_id") & "' And outer_oi_id = '" & dr("outer_oi_id") & "'"
cmd.CommandText = "Se lect Count(*) from {orderItems} Where " & f
Output.Show(cmd.ExecuteScalar)
输出 0
If dr.IsNull("outer_oi_id") Then
f = "o_id = '" & dr("o_id") & "' And oi_id = '" & dr("oi_id") & "' And outer_oi_id is null "
End If
cmd.CommandText = "Se lect Count(*) from {orderItems} Where " & f
Output.Show(cmd.ExecuteScalar)
输出 5