2015-08-14 109 views
0

我正在使用VBScript处理传入的文本消息。我有一个条件,如果传入值低于数据库中的值,则会向发送者发送一条消息。由于某些原因,即使值较高,消息集仍然正在发送。小于或等于不工作

基本上,变量arrmessage包含一个数字,例如300,然后将其与变量val进行比较,该变量是数据库表中称为出价的最大值。因此,例如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

你确定arrmessage和val都是数字,哪一个都不是字符串? –

+1

'arrmessage'从哪里来?它可能是一个字符串? –

+1

'MsgBox TypeName(arrmessage)'报告什么? – Bond

回答

1

我的猜测是,arrmessage不是数字,可能是这个问题在你update说法引起。围绕arrmessage变量的单引号在字符串连接中的前面有一个空格,因此它总会为您写出的每个出价的结尾添加一个空格。事实上,我很惊讶,因为where之前没有空格,所以update也不会返回语法错误。另外,在准备update之前,您应该再次初始化之前明确关闭数据库连接。