插入SQL时,我有可为空的列机器ID。如果字段中有某些类型,我希望它检查该值是否存在。这很好。但是,因为它不是必需的表项,我希望它忽略该字段,如果为空,只需插入null。现在我已经尝试了几种不同的方式,即使是空的,它也会继续验证字段,或者在没有验证的情况下添加所有内容。这是最新的尝试:
If IsDBNull(DataGridView3.Rows(i).Cells("Machine ID").Value) = False Then
STSQL = "select machine_id from mpcs.machine where machine_id = " & "'" & DataGridView3.Rows(i).Cells("Machine ID").Value & "'"
rsMPCS = MPCS_SELECT_SQL(UCase(STSQL), rsMPCS)
If Not rsMPCS.HasRows Then
MessageBox.Show("Not a valid Machine ID")
Return
End If
rsMPCS.Close()
ElseIf IsDBNull(DataGridView3.Rows(i).Cells("Machine ID").Value) = True Then
DataGridView3.Rows(i).Cells("Machine ID").Value = vbNull
End If
好的我用这种方式判断它。
If MachID = Nothing Then
MachID = vbNull
Else
STSQL = "select machine_id from mpcs.machine where machine_id = " & "'" & DataGridView3.Rows(i).Cells("Machine ID").Value & "'"
rsMPCS = MPCS_SELECT_SQL(UCase(STSQL), rsMPCS)
If Not rsMPCS.HasRows Then
MessageBox.Show("Not a valid Machine ID")
Return
End If
rsMPCS.Close()
End If
答案 0 :(得分:0)
如果我没弄错,那应该是
public class CharacterGenerator : MonoBehaviour
{
private PlayerCharacter _toon;
}
你的if条款错了。正确的语法是DataGridView3.Rows(i).Cells("Machine ID").Value = nothing