|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Why does the the program not quit in this case?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: 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 > .... 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 >> .... > 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 >>> .... >> > > 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 > .... > > > >
Embedding a newline in a vb.net string constant
OLEDBCommand vs. SQLCommand convet date format MDI Parent Forms Exe Size Re: Which do you prefer? XML File into a SQL table how pass Date vaiable to XPath query DLL returns a variant data type - how to convert and use in VB .NET Setting Tab Index between Panels |
|||||||||||||||||||||||