> > I'm having difficulty communicating what the real
> > issue is here: that the grid works, but the textbox doesn't. Doing the
> > textbox the "right way" still doesn't work. I've tried it and posted 
> code earlier.
> > Doing the grid "any old way" works.
> >
> > Can you please provide some insight on this issue?
>
>         There are two problems, as I see it. First, and most importantly,
>the text control needs to have both of its data binding properties
>set.
>
>         Second, the requery needs to be called on the form, so that the 
> form
>can raise an Update event. The control reacts to Update by refreshing
>its value from its DataSource/DataField.

Thanks again.

I've reconfigured the form in proper OO style and implemented all of your 
suggestions.
I can report some progress, in that I can now get something to appear in 
the textbox, but not what I want when I want.

If I requery the bizobj right after I set it up, the grid populates and the 
first song appears in the textbox. However, pressing my button to get a 
particular record by PK and put the songname into the textbox still does 
not work. I get errors indicating a problem with the pkid field. The field 
exists and can be accessed, as the grid demonstrates. I can execute the 
same query in the MySQL command line client and it returns the row I expect.

Code and traceback are below. What next?

Ken

code.py file:

## *!* ## Dabo Code ID: dButton-dForm
def onHit(self, evt):
         self.Form.selectSong()

## *!* ## Dabo Code ID: dForm-top
def afterInit(self):
         self.setupBizobj()

def afterInitAll(self):
         self.populateGrid()

def populateGrid(self):
         # Just like in the Wiki How-To:
         self.gridKen.DataSource = "musSongs"

def selectSong(self):
         # Try to show just one song in the thisSong textbox,
         # assuming the user entered a number in the keyBox.
         myPK = self.keyBox.Value

         self.PrimaryBizobj.UserSQL = "select songname from musSongs where 
pkid = " + myPK

         # This, or the following line, throws an error.

         # If I comment out this line, and also comment out the
         # biz.requery() line in setupBizobj(), then the
         # "please wait...requerying dataset..." message flashes
         # briefly. If I press the button a second time, that
         # window appears and stays, and a "Requery not allowed"
         # message window appears on top of it, with the message:
         # "Field 'pkid' does not exist in the dataset". I don't
         # get anything in the textbox. A traceback is generated.

         # If I let this line run, I don't get any of those
         # messages, but I don't get anything in the textbox.
         # The same traceback as above is generated.
         #self.PrimaryBizobj.requery()

         # Whether or not this line is commented out makes no
         # difference. Nothing in the textbox, same traceback.
         self.requery()

         # This is here because, when I let the grid be
         # populated, the appearance of the above-described
         # messages blanks out the area of the grid they
         # were over.
         self.refresh()

def setupBizobj(self):
         """Set up the Bizobj"""

         
self.Application.addConnectFile("C:\DaboProjects\MyMusic\mymusic.cnxml")

         conn = self.Application.getConnectionByName("main")

         biz = dabo.biz.dBizobj(conn)

         biz.DataSource = "musSongs"
         biz.KeyField = "pkid"

         biz.addField("pkid")
         biz.addField("songname")
         biz.addField("compdate")

         self.addBizobj(biz)

         # If this line runs, I get the first song in the table
         # in natural order in the thisSong textbox. However,
         # entering another number in the keyBox textbox and
         #p ressing the button STILL doesn't work. It throws
         # an error.
         #biz.requery()

.cdxml file:

<?xml version="1.0" encoding="utf-8" standalone="no"?>
<dForm code-ID="dForm-top" Name="dForm" Caption="Songs" Top="17" 
Height="546" Width="682" designerClass="DesForm" UseSizers="True" Left="312">
         <dSizer SlotCount="4" designerClass="LayoutSizer" 
Orientation="Vertical">
                 <dGrid ColumnCount="3" RegID="gridKen" 
SelectionMode="Cell" designerClass="controlMix" sizerInfo="{'BorderSides': 
['All'], 'Proportion': 1, 'HAlign': 'Left', 'VAlign': 'Top', 'Border': 0, 
'Expand': True}">
                         <dColumn HeaderFontItalic="False" 
FontUnderline="False" Width="150" FontFace="Arial" HeaderBackColor="None" 
FontBold="False" HeaderVerticalAlignment="None" Editable="False" 
HeaderFontBold="True" ListEditorChoices="[]" FontItalic="False" 
Expand="False" HeaderFontSize="9" Sortable="True" HeaderFontFace="Arial" 
Caption="ID" designerClass="controlMix" Order="0" FontSize="9" 
HeaderForeColor="None" Searchable="True" HeaderFontUnderline="False" 
HeaderHorizontalAlignment="None" HorizontalAlignment="Left" 
DataField="pkid" VerticalAlignment="Top"></dColumn>
                         <dColumn HeaderFontItalic="False" 
FontUnderline="False" Width="150" FontFace="Arial" HeaderBackColor="None" 
FontBold="False" HeaderVerticalAlignment="None" Editable="False" 
HeaderFontBold="True" ListEditorChoices="[]" FontItalic="False" 
Expand="False" HeaderFontSize="9" Sortable="True" HeaderFontFace="Arial" 
Caption="Song" designerClass="controlMix" Order="10" FontSize="9" 
HeaderForeColor="None" Searchable="True" HeaderFontUnderline="False" 
HeaderHorizontalAlignment="None" HorizontalAlignment="Left" 
DataField="songname" VerticalAlignment="Top"></dColumn>
                         <dColumn HeaderFontItalic="False" 
FontUnderline="False" Width="150" FontFace="Arial" HeaderBackColor="None" 
FontBold="False" HeaderVerticalAlignment="None" Editable="False" 
HeaderFontBold="True" ListEditorChoices="[]" FontItalic="False" 
Expand="False" HeaderFontSize="9" Sortable="True" HeaderFontFace="Arial" 
Caption="Date" designerClass="controlMix" Order="20" FontSize="9" 
HeaderForeColor="None" Searchable="True" HeaderFontUnderline="False" 
HeaderHorizontalAlignment="None" HorizontalAlignment="Left" 
DataField="compdate" VerticalAlignment="Top"></dColumn>
                 </dGrid>
                 <dTextBox RegID="keyBox" sizerInfo="{'BorderSides': 
['All'], 'Proportion': 0, 'HAlign': 'Left', 'VAlign': 'Top', 'Border': 3, 
'Expand': False}" designerClass="controlMix"></dTextBox>
                 <dButton code-ID="dButton-dForm" Caption="Button" 
sizerInfo="{'BorderSides': ['All'], 'Proportion': 0, 'HAlign': 'Left', 
'VAlign': 'Middle', 'Border': 4, 'Expand': False}" 
designerClass="controlMix"></dButton>
                 <dTextBox sizerInfo="{'BorderSides': ['All'], 
'Proportion': 0, 'HAlign': 'Left', 'VAlign': 'Top', 'Border': 3, 'Expand': 
False}" Name="dTextBox1" designerClass="controlMix" DataSource="musSongs" 
RegID="thisSong" DataField="songname"></dTextBox>
         </dSizer>
</dForm>

Traceback (most recent call last):
   File "C:\Program Files\Dabo Runtime\dabo\lib\eventMixin.py", line 97, in 
raiseEvent
   File "c:\docume~1\kend\locals~1\temp\tmp6onu0b.py", line 151, in onHit
   File "c:\docume~1\kend\locals~1\temp\tmp6onu0b.py", line 136, in selectSong
   File "C:\Program Files\Dabo Runtime\dabo\biz\dBizobj.py", line 707, in 
requery
   File "C:\Program Files\Dabo Runtime\dabo\biz\dBizobj.py", line 852, in 
_moveToPK
   File "C:\Program Files\Dabo Runtime\dabo\db\dCursorMixin.py", line 1379, 
in moveToPK
   File "C:\Program Files\Dabo Runtime\dabo\db\dCursorMixin.py", line 1362, 
in _getRecordByPk
KeyError: 'pkid' 


-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.446 / Virus Database: 268.18.5/706 - Release Date: 2/28/2007 4:09 
PM



_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users

Reply via email to