Home > ASP Development > Stop executing the code - help needed, thx

Stop executing the code - help needed, thx



Sorry, can anybody tell me how to stop the code from executing after the IF condition is false?



If (qua="Q1") then

eng = trim(rs("Q2Eng"))

pro = trim(rs("Q2Pro"))

aEng = trim(rs("Q1Eng"))

aPro = trim(rs("Q1Pro"))

<!--If ((eng="0") OR (pro="0")) then

msgbox = "You have no diskspace to request"

End If-->

End If



If (qua="Q1") then

sql = "UPDATE DF_Year SET Q1Eng = '" & addEng & "', Q1Pro = '" & addPro & "', Q2Eng = '" & minusEng & "', Q2Pro = '" & minusPro & "' WHERE Forecast_ID = '" & ID & "' AND Fo_Year = '" & myYear & "'"

set rs = strconn.Execute(sql)

End If



How can i stop the coding from updating my database if either eng or pro = "0" ?

    
Guest


write this to stop executing




Code:



response.end



Was this answer helpful ? Yes No   
Guest


Since you have 2 if statement with the same condition, and validation is done only in the 1st IF statement,the sql will get executed. So, try something like below


Code:



If (qua="Q1") then
eng = trim(rs("Q2Eng"))
pro = trim(rs("Q2Pro"))
aEng = trim(rs("Q1Eng"))
aPro = trim(rs("Q1Pro"))

If ((eng<>"0") OR (pro<>"0")) then

sql = "UPDATE DF_Year SET Q1Eng = '" & addEng & "', Q1Pro = '" & addPro & "', Q2Eng = '" & minusEng & "', Q2Pro = '" & minusPro & "' WHERE Forecast_ID = '" & ID & "' AND Fo_Year = '" & myYear & "'"
set rs = strconn.Execute(sql)
else
msgbox = "You have no diskspace to request"

End If
End If







hope it helps

Was this answer helpful ? Yes No   
Guest


Thank you very much for your help. By the way, do you know why this msgBox dosen't work?



If ((eng="0") OR (pro="0")) then

msgbox = "You have no diskspace to request"

response.End

End If



It comes out with problem : Illegal Assignment

What's wrong?

Was this answer helpful ? Yes No   
Guest


Is there any predefine function that i need to write for that? Or MsgBox is a build-in fucntion?

Was this answer helpful ? Yes No   
Guest


this code--------
msgbox = "You have no diskspace to request"

change to.................................
msgbox("You have no diskspace to request")

Was this answer helpful ? Yes No   
Guest


u can use javascript to for a message box

Was this answer helpful ? Yes No   
Guest


example code




Code:




<head>
<script language="JavaScript">
function msg1()
{
alert("Welcome");
}
</script>
</head>
<body onload="msg1()">

</body>



Was this answer helpful ? Yes No   
Guest


But MsgBox("You have no sufficient diskspace") also comes out with error : Permisson Denied

Was this answer helpful ? Yes No   
Guest


in asp script tag u can not use msgbox().
try this :
<script language="vbscript runat="server">
------------code-----------
</script>

Was this answer helpful ? Yes No   
Guest
 
 
Home - About Infoqu - Contact - Privacy Statement - Link to Infoqu - Bookmark Infoqu

Copyright 2007-2008 by Infoqu. All rights reserved