我编写了这段代码来比较实际值和用户输入的值。我在名为 Spec 的表中设置了实际值
sampleID Category WheatType Silo M_Min M_Max WG_Min WG_Max
1001 1BK AGP 1 25.00 27.00
1002 1BK AGP 21 25.00 28.00
这是比较值的代码
sql = "SELECT * FROM Spec WHERE WheatType= '" & ddlType.SelectedValue & "' AND Category='1BK' AND Silo='" & txtSilo.Text & "'"
cmd = New OleDbCommand(sql, cnnOLEDB)
cnnOLEDB.Open()
Dim dr As OleDbDataReader
dr = cmd.ExecuteReader()
While dr.Read()
Try
If txtHB43S.Text >= dr("M_Min").ToString() And txtHB43S.Text <= dr("M_Max").ToString() Then
stsHB43S.Text = "Pass"
ElseIf txtHB43S.Text <= dr("M_Min").ToString() And txtHB43S.Text >= dr("M_Max").ToString() Then
stsHB43S.Text = "Failed"
stsHB43S.ForeColor = System.Drawing.Color.Red
ElseIf txtHB43S.Text <> dr("M_Min").ToString() And txtHB43S.Text <> dr("M_Max").ToString() Then
stsHB43S.Text = ""
Else
stsHB43S.Text = ""
End If
If txtGlutematic.Text >= dr("WG_Min").ToString() And txtGlutematic.Text <= dr("WG_Max").ToString() Then
stsGluten.Text = "Pass"
ElseIf txtGlutematic.Text <= dr("WG_Min").ToString() And txtGlutematic.Text >= dr("WG_Max").ToString() Then
stsGluten.Text = "Failed"
stsGluten.ForeColor = System.Drawing.Color.Red
ElseIf txtGlutematic.Text <> dr("WG_Min").ToString() And txtGlutematic.Text <> dr("WG_Max").ToString() Then
stsGluten.Text = ""
Else
stsGluten.Text = ""
End If
问题是如果我只输入 的值txtHB43S.Text = 25.00, Silo=1 and WheatType='AGP'
,状态将显示'Pass'
在stsHB43S
但它在 stsGluten 中也会显示'pass'
。
输出
HB43s = 25.00 stsHB43S=Pass
Gluten = - stsGluten =Pass
谁能帮我