VB查询数据库问题

来源:百度知道 编辑:UC知道 时间:2024/05/14 02:49:09
请教高手们,我想要查询Storage里的remaining_places是否大于我输入的文本框数据,如果是remaining_places大于我输入的文本框数,然后才执行以下操作,应该怎么写

Set rs = cn.Execute("SELECT * FROM Product WHERE Produk_Type='"& Trim(Combo1.text) & "'")
If rs.Fields("Produk_Type") = Trim(Combo1.text) Then
Text13.text = rs.Fields("Stok_Type")

Set rs = cn.Execute("SELECT * FROM Storage WHERE Storage_Type='" & Text13.text & "'")

If rs.Fields("Storage_Type") = Text13.text Then
Text12.text = rs.Fields("Storage_Place").Value

End If
End If

Set rs = cn.Execute("select remaining_places from Storage where Storage_Type='" & Text13.text & "'")
rs.MoveFirst
Text4.text = rs.Fields("remaining_places")
text = Val(Text4.text)
t11 = Val(Text11.text)
t12 = text - t11
Text12.text = t12

Adodc1.Recordset.Fields("remaini

Set rs_tmp = cn.Execute("SELECT * FROM Storage WHERE remaining_places>" & Text1.text)
if not rs_tmp.eof then
'...你要执行的代码
end if

Set rs1 = cn.Execute("SELECT * FROM Storage WHERE remaining_places>"&Text1.text&")
if rs1.RecordCount>0 then
'你要执行的代码
end if

你只需要事先把Storage里的remaining_places取到,放在变量里,之后把它与你输入的数据比较,大于你输入的就执行你上面的语句,否则跳过这段代码就可以了.

SELECT * FROM Storage WHERE Storage_Type= Text13.text And remaining_places > Text12.text