> A better choice, IMO, would be to not mess with UserSQL at all, and
>instead continue to work with the SQL Builder code. In this
>particular case, you want to find a record based on PK. I would
>approach it like this: set the where clause to take a parameter, and
>then pass the desired value when you need it. Example:
>
>biz.setWhere("pkid = %s")
>
>#User enters '123' as the PK and clicks
>biz.setParams(self.keyBox.Value)
>self.requery()
>
>#User enters '876' as the PK and clicks
>biz.setParams(self.keyBox.Value)
>self.requery()
>
> I hope this helps.
Thanks, Ed. I really wanted this to work, but it doesn't.
Basically, putting that stuff in the setupBizobj() method causes the form
not to run. The error is: "Form has no attribute 'keyBox'"
Putting it in the selectSong() method, which gets called by the button
onHit(), doesn't work either. I get "AttributeError: 'dBizobj' object has
no attribute 'setWhere'"
I think you wanted me to put
biz.setWhere("pkid = %s")
in the setup method, and
[valid object reference to the biz object].setParams(self.keyBox.Value)
in the selectSong() method.
I tried that too. Same results.
Code is below.
Ken
## *!* ## 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):
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
# Neither of these lines for setParms() throws an
# error, but I assume only one can be right.
#self.PrimaryBizobj.setParams("%self.keyBox.Value%")
self.PrimaryBizobj.setParams(self.keyBox.Value)
# Causes:
# "AttributeError: 'dBizobj' object has no attribute
# 'setWhere'"
self.PrimaryBizobj.setWhere("pkid = %s")
self.requery()
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")
# "Form has no attribute 'keyBox'" on either of these
# lines, so I guess this gets run before the controls
# are constructed.
#biz.setParams("%self.keyBox.Value%")
biz.setParams(self.keyBox.Value)
#biz.setWhere("pkid = %s")
self.addBizobj(biz)
# If this is here, I get the first song in the table
# in natural order in the thisSong textbox. However,
# entering another number in the keyBox textbox and
# pressing the button STILL doesn't work.
#biz.requery()
--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.446 / Virus Database: 268.18.6/708 - Release Date: 3/2/2007 4:19 PM
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users