I've can't claim best practice, but I notice in some of my older stacks I've commented out<br>vDatabase_IsOpen(tDbRef)<br>or<br>vConnection_IsConnected(tDbRef)<br>and ended up with <br>Valentina_DatabaseCount()<br>
<br>The first two return TRUE if you have a connection, and are empty if not. The last one returns the number of connected DBs or 0 if none.<br><br>In my case I've used a simple IF statement to test for a connection and if not I pop up an ask dialog to advise that the DB is no longer connected and that I need to reconnect with the choice to cancel or proceed.<br>
<br>if (Valentina_DatabaseCount() = 0) then --no DB connection<br> ask "The DB Connection is lost. Do you wish to reconnect?" with "No" or "Yes" titled "DB Connection Lost"<br> put it into tAnswer<br>
if (tAnswer = "Yes) then<br> put fDbOpen() into tDbRef<br> put fDbQuery(tQuery,tDbRef) into tData<br> else --don't proceed<br> exit to top<br> end if<br>else --there is a DB connection<br> put fDbQuery(tQuery,tDbRef) into tData<br>
end if<br><br>I can't remember why I abandoned the first two in favour of the last.<br><br>In my case I'm only currently dealing with single embedded DBs (although tentatively playing with using V Office Server - see previous posts) so Valentina_DatabaseCount() gives me an answer that is suitable. I imagine in a Server environment where you may be connected to several DBs a simple count will not give you the necessary info that you have a valid connection to a particular DB. Where multiple DBs are involved I'd assume _IsConnected(tDbRef) or _IsOpen(tDbRef) would provide a definitive response.<br>
<br>HTH<br><br><div class="gmail_quote">On Mon, May 14, 2012 at 8:43 AM, william humphrey <span dir="ltr"><<a href="mailto:bill@bluewatermaritime.com" target="_blank">bill@bluewatermaritime.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I have another question about best practice. It's true I'm testing the new betas and one thing that happens when you do that is you get the old defaults that times-out your vServer connection. So I have to go find that init file and increase the time but I was thinking.<div>
<br></div><div>Does anyone have a suggestion using LiveCode to pop-up a warning that the database connection has failed? I could see this being very useful say the server went down. Right now when the connection goes down I get a whole string of errors from calls that fail. It would be better to get one nice message.</div>
<div><br></div><div>Can anyone help me with this LiveCode programming request?</div>
<br>_______________________________________________<br>
Valentina mailing list<br>
<a href="mailto:Valentina@lists.macserve.net">Valentina@lists.macserve.net</a><br>
<a href="http://lists.macserve.net/mailman/listinfo/valentina" target="_blank">http://lists.macserve.net/mailman/listinfo/valentina</a><br>
<br></blockquote></div><br>