Why does the the program not quit in this case?

  • Thread starter Thread starter Bob
  • Start date Start date
B

Bob

Hi,

If the test is true, the message 'not available' must be shown and quit the
program.
But when the test is true and when table 'data2' is empty (so nrg=0), i get
the error:"dividing by zero". Why? The program should quit, no?

Thanks
Bob

the code:
.....
x= Date.Now
sql = "select begindate from mydate"
comd = New OleDbCommand(sql, oConnection)
dtreader = comd.ExecuteReader
dtreader.Read()
If x <= dtreader.GetDateTime(0) Then 'compare today with date
in table
Page.ClientScript.RegisterClientScriptBlock(Me.GetType(),
"myscript", _
" alert(not available);" & _
" window.location.href='http://www..../';", True)
End If
' should stop here if test is true
dim z, nrg as integer
sql = "select count(*) from data2 ;"
comd = New OleDbCommand(sql, oConnection)
nvrg = comd.ExecuteScalar
z=10/nrg
.....
 
Hi B

you did not put any Exit sub / function
or similar, why do you expect it does not continue after the End if ?

-P

Bob ha scritto:
 
That is not the command being executed.

The command being executed is to write that string out to the response
stream. Then it keeps going.

Once the page is done processing, the response stream will be sent to the
browser. The browser will then render the HTML and execute any scripts.

There is a big disconnect between the server and the client. Client side
code does not execute until the browser receives the response stream. But
that doesn't happen until the page is done processing and the response gets
to the browser.
 
Bop,

Put in top of your code page
"Option Strict On" than you will see many errors which are now not seen.

Your dividing by zero will probably be if the connection does not exist.
However without that Option Strict On the behaviour is mostly not real good
predictable.

Cor
 
Back
Top