Edit history

Edit: -1 of 1
Time: 2007-09-19 10:45:52
Note: /dabosite/wiki/HowTos/edit

added:
<P STYLE="margin-bottom: 0in">Occasionally you may need a temporary
cursor to access tables.   There are several ways to access the
database via cursors.  But the best way does not violate Dabo's 3
tier design and most importantly does not cause other issues with
Dabo.  
</P>
<P STYLE="margin-bottom: 0in">Below is an example of how I did it.</P>
<P STYLE="margin-bottom: 0in"><BR>
</P>
<P STYLE="margin-bottom: 0in">I add the following to the forms
“createBizobjs()”</P>
<P STYLE="margin-bottom: 0in"><BR>
</P>
<P STYLE="margin-bottom: 0in"><B>self.biztmp =
dabo.biz.dBizobj(self.Connection)</B></P>
<P STYLE="margin-bottom: 0in"><B>self.tmpbiz =
self.biztmp.getTempCursor()</B></P>
<P STYLE="margin-bottom: 0in"><BR>
</P>
<P STYLE="margin-bottom: 0in">Note:</P>
<P STYLE="margin-bottom: 0in">self.Connection is the name of the
Form's connection to the database.  And I did not add the bizobj to
the form (do not -&gt; “self.addBizobj(self.biztmp)”)</P>
<P STYLE="margin-bottom: 0in"><BR>
</P>
<P STYLE="margin-bottom: 0in">Now I can use “self.tmpbiz”
anywhere on the form as I would any other bizobj.  So I can:</P>
<P STYLE="margin-bottom: 0in"><B>self.tmpbiz.execute(“select
somefield from sometable”)</B></P>
<P STYLE="margin-bottom: 0in">and the bizobj “self.tmpbiz” will
contain the retreived data in the DataSet.  
</P>
<P STYLE="margin-bottom: 0in"><BR>
</P>
<P STYLE="margin-bottom: 0in">In my case I decided to create a
special bizobj to make it easier to identify in code.  But you could
have used any bizobj that the form knows about.  So if the form has a
bizobj named “CustomerBizObj” you can use it to create a
temporary cursor.</P>
<P STYLE="margin-bottom: 0in"><BR>
</P>
<P STYLE="margin-bottom: 0in"><B>myTempCursor =
self.Form.CustomerBizObj.getTempCursor().</B></P>
<P STYLE="margin-bottom: 0in"><BR>
</P>
<P STYLE="margin-bottom: 0in">The above will not
change/touch/overwrite the CustomerBizObj data.</P>
<P STYLE="margin-bottom: 0in"><BR>
</P>
<P STYLE="margin-bottom: 0in"><BR>
</P>
<P STYLE="margin-bottom: 0in"><BR>
</P>
<P STYLE="margin-bottom: 0in"><BR>
</P>
<P STYLE="margin-bottom: 0in"><BR>
</P>
<P STYLE="margin-bottom: 0in"><BR>
</P>
<P STYLE="margin-bottom: 0in"><BR>
</P>
<P STYLE="margin-bottom: 0in"><BR>
</P>
<P STYLE="margin-bottom: 0in"><BR>
</P>