General information
Category:
Databases,Tables, Views, Indexing and SQL syntax
Hi Garrett. When I try to do an update in the 'Runtime' version I get a message the primary key has been corrupted, and I am given the opportunity to revert the entry. When I do the same thing using the executable for the program (not the runtime) it works flawlessly. I am at a loss. I am taking the liberty of including the code I am using. It is an extract from a reply I made to Tom O'Hare of VFUG, who took me to task for several of my bad habits....
Tom, to clarify what I am doing :
The work area is the _screen.activeform. primarytable which is the Alias() in question.
oApp.incrid() automatically increases the vaue of the primary key for the alias in question every time an entry is made.
It is a 'One size fits all' situation that I use on ALL my tables and primary keys. It works well, and it saves a lot of coding.
As for 'm' in front for the variables...old bad habit I guess. No excuse. I cannot think at this time why I made the variables Public, they don't have to be. I will take your observation to heart and try to do better.
When an update is being made..a check to see if the amount of the new bid is not <= to the exisiting amount. A further check verifies if there is an existing primary key. (The user is unable to ADD a new entry, and thus create a primary key) The record is marked for 'Deletion and a 'set carry' is put on the item number and the item. The new primary key, data etc..is inserted into the table. If all is well, the record is saved and we move on. It is really simple and it works as an executable but NOT in the runtime version. There, as old William would say, lies the rub.
LOCAL m.lcOriWA
m.lcOriWA = _SCREEN.ACTIVEFORM.primarytable
SELECT &lcOriWA
LOCAL lcNaTable, lcNaCurKey, lcNewKey
PUBLIC nAmount, cName, cCode, cPhone
m.lcNaTable = ALIAS()
m.lcNaCurKey = "cID" + left(alias(), 4)
m.lcNewKey = oApp.incrid( m.lcNaCurKey )
m.nAmount = (auction.nAmount)
m.cName = (auction.cName)
m.cCode = (auction.cCode)
m.cPhone = (auction.cPhone)
IF !EMPTY( m.lcNewKey )
DELETE
SET CARRY TO nitem_num, citem
INSERT INTO &lcNaTable (&lcNaCurKey,nitem_num,citem,nAmount, ctime) VALUES (m.lcNewKey,nitem_num,citem,nAmount, TIME())
=TABLEUPDATE(.T.)
_SCREEN.ACTIVEFORM.REFRESH()
ELSE
=MESSAGEBOX("Record not added")
ENDIF
THISFORM.pgf2base1.page1.txtnBid.SETFOCUS
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only