IF/Else statement not working
Question ID: 104869
1
0

IF/ELSE statement is not working: See below code example:

If dtSystemDate = dtMyDate Then

msgbox "dtSystemDate = dtMyDate"

Set rcMyRecords = DBO.Execute("Update recorddate set locdt = (SELECT TO_CHAR(SYSDATE) FROM location) where locnbr = " & my_Variable.Item("LocNbr") & "and locdtcd = ‘ABC"’)

Else
msgbox "dtSystemDate <> dtMyDate"

End If

But BOTH msgboxes are being displayed!!

Marked as spam
Posted by (Questions: 387, Answers: 66)
Asked on February 28, 2013 8:13 pm
41 views
Answers (1)
2
Private answer

This usually happens when a statement within the IF/Else causes a run-time error. Double check your database connection setting and your query. You might also want to wrap your code in error-handling code. You can find instructions on how to do that here: http://blogs.msdn.com/b/ericlippert/archive/2004/08/19/error-handling-in-vbscript-part-one.aspx

HP has a knowledge base article about this situation (note it can also happen in Select Case statements):
KM524633 - QuickTest Pro - Proceed to next step behaves incorrectly with case and if (http://support.openview.hp.com/selfsolve/document/KM524633)

Marked as spam
Posted by (Questions: 17, Answers: 807)
Answered on February 28, 2013 8:25 pm
0
That's exactly what was going on. Our database connection string was wrong. Once I got it fixed, the code worked perfectly! I'll be checking out that error-handling stuff too. Thanks!
( at February 28, 2013 8:41 pm)
EyeOnTesting

Welcome back to "EyeOnTesting" brought to you by Orasi Software, Inc.

X
Scroll to Top