我想将 喷标号Text4和Text5之间的数出库,请问以下代码哪错了,为什么当Text4 Text5分别输入1,2时 ,喷标号为12 , 14等数据也添加成功Dim se As New ADODB.Recordset
se.Open "select * from 成品档案 where 炉批号='" + Trim(Text1.Text) + "'and 喷标号 >= '" & Val(Trim(Text4.Text)) & "' and 喷标号<= '" & Val(Trim(Text5.Text)) & "'and 发货否='" + Trim(Text7.Text) + "'and 借出否='" + Trim(Text7.Text) + "'and 报废否='" + Trim(Text7.Text) + "'", cnn, adOpenKeyset, adLockOptimistic
If se.RecordCount > 0 Then
cnn.Execute ("update 成品档案 set 发货否='" & Text6 & "',客户单位='" & Text2 & "',发货日期='" & DTPicker1.Value & "',经办人='" & Text3 & "' where 炉批号='" & Text1 & "'and 喷标号 >= '" & Val(Trim(Text4.Text)) & "' and 喷标号<= '" & Val(Trim(Text5.Text)) & "'")
se.Update
MsgBox "记录添加成功!", , "成品管理系统"
Adodc1.Refresh
Else
MsgBox "信息不符!", , "成品管理系统"
Exit Sub
End If我数据库中喷标号数据类型为文本改成数字也不行
se.Open "select * from 成品档案 where 炉批号='" + Trim(Text1.Text) + "'and 喷标号 >= '" & Val(Trim(Text4.Text)) & "' and 喷标号<= '" & Val(Trim(Text5.Text)) & "'and 发货否='" + Trim(Text7.Text) + "'and 借出否='" + Trim(Text7.Text) + "'and 报废否='" + Trim(Text7.Text) + "'", cnn, adOpenKeyset, adLockOptimistic
If se.RecordCount > 0 Then
cnn.Execute ("update 成品档案 set 发货否='" & Text6 & "',客户单位='" & Text2 & "',发货日期='" & DTPicker1.Value & "',经办人='" & Text3 & "' where 炉批号='" & Text1 & "'and 喷标号 >= '" & Val(Trim(Text4.Text)) & "' and 喷标号<= '" & Val(Trim(Text5.Text)) & "'")
se.Update
MsgBox "记录添加成功!", , "成品管理系统"
Adodc1.Refresh
Else
MsgBox "信息不符!", , "成品管理系统"
Exit Sub
End If我数据库中喷标号数据类型为文本改成数字也不行
se.Open "select * from 成品档案 where 炉批号='" + Trim(Text1.Text) + "' and CAST(喷标号 AS int) >= '" & clng(Text4.Text)) & "' and CAST(喷标号 AS int)<= '" & clng(Text5.Text)) & "' and 发货否='" + Trim(Text7.Text) + "' and 借出否='" + Trim(Text7.Text) + "' and 报废否='" + Trim(Text7.Text) + "'", cnn, adOpenKeyset, adLockOptimistic
数字型比较时:12<13<14
字符串比较时: 12<14<2