小于或等于不工作

时间:2015-08-14 19:50:28

标签: vbscript

我正在使用VBScript处理传入的短信。我有一个条件,如果传入的值低于数据库中的值,邮件将被发送给发件人。出于某种原因,即使值较高,仍然会发送消息集。

基本上变量arrmessage包含一个数字,例如300,然后将其与变量val进行比较,变量{database}是数据库表中的最大值,称为bid。例如val = 10

当我放置arrmessage <= val then... elseif arrmessage > val then时 它总是告诉我arrmessage低于val,即使它更高。

Set objConn = CreateObject("ADODB.Connection")
set mycommand = CreateObject("ADODB.COMMAND")

objConn.Open "Provider=SQLOLEDB.1;Data Source=OFFICE-PC\SQLEXPRESS Initial Catalog=SMSSERVER","sa","Password1"
set highestbid = objConn.execute("select max(bid) from bid")
val = highestbid.fields(0).value
highestbid.close

IF arrmessage <= val then
  strResponse = "Your bid is " & arrmessage & " and the highest bid is " & (val) & " you need to out bid the highest bidder"
elseif arrmessage > val then
  'continue and insert bid in table
  Set objConn = CreateObject("ADODB.Connection")
  set mycommand = CreateObject("ADODB.COMMAND")
  objConn.Open "Provider=SQLOLEDB.1;Data Source=OFFICE-PC\SQLEXPRESS;  Initial Catalog=SMSSERVER","sa","Password1"
  set mycommand = objConn.execute("update bid set bid='"& arrmessage & " 'where  msisdn='" & objMessageIn.FromAddress & "'")
  strResponse = "Thanks your bid of " & arrmessage & " has been recorded. To query the highest bid text keyword query"
else

1 个答案:

答案 0 :(得分:1)

我的猜测是arrmessage不是数字,可能是由update语句中的问题引起的。围绕arrmessage变量的单引号在字符串连接中前面有一个空格,因此它总是会在您写出的每个出价的末尾添加一个空格。事实上,我很惊讶updatewhere之前没有空格的情况下不会返回语法错误。此外,在准备update之前,应该再次初始化之前显式关闭数据库连接。