Home All Groups Group Topic Archive Search About

Why does the the program not quit in this case?

Author
6 Dec 2006 6:26 PM
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
.....

Author
6 Dec 2006 6:37 PM
pamelafluente
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:

Show quoteHide quote
> 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
> ....
Author
6 Dec 2006 8:59 PM
Bob
Hi P,
because of  the comand:
window.location.href='http://www..../';", True
i thought ...

<pamelaflue***@libero.it> schreef in bericht
Show quoteHide quote
news:1165430230.806362.290630@l12g2000cwl.googlegroups.com...
> 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:
>
>> 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
>> ....
>
Author
6 Dec 2006 9:08 PM
Marina Levit [MVP]
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.

Show quoteHide quote
"Bob" <gtdbd> wrote in message news:eXovxlXGHHA.924@TK2MSFTNGP02.phx.gbl...
> Hi P,
> because of  the comand:
> window.location.href='http://www..../';", True
> i thought ...
>
> <pamelaflue***@libero.it> schreef in bericht
> news:1165430230.806362.290630@l12g2000cwl.googlegroups.com...
>> 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:
>>
>>> 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
>>> ....
>>
>
>
Author
7 Dec 2006 5:24 AM
Cor Ligthert [MVP]
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

Show quoteHide quote
"Bob" <gtdbd> schreef in bericht
news:exFpYQWGHHA.1188@TK2MSFTNGP06.phx.gbl...
> 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
> ....
>
>
>
>