Author | Topic: :getdata() bug | |
---|---|---|
Joe Carrick | :getdata() bug on Tue, 17 Aug 2010 09:47:03 -0700 I use the following code which does not result in an error: ////////////////////////////////////////////////////////////// IF empty(aControls[10]:editbuffer()) select 0 netuse(cCompanyDir+"ACOMP","Comp") Comp->(DbGotop()) aControls[10]:setdata(Comp->Company) aControls[11]:setdata(Comp->Address1) aControls[12]:setdata(Comp->Address2) aControls[13]:setdata(Comp->City) aControls[14]:setdata(Comp->State) aControls[15]:setdata(Comp->Zip) select Vendors DO WHILE !Vendors->(DbrLock()) ENDDO replace Vendors->sCompany with Comp->Company,; Vendors->sAddress1 with Comp->Address1,; Vendors->sAddress2 with Comp->Address2,; Vendors->sCity with Comp->City,; Vendors->sState with Comp->State,; Vendors->sZip with Comp->Zip Vendors->(DbrUnlock()) NetClose("Comp") ENDIF ////////////////////////////////////////////////////////////// but if I use the following I get a runtime error: ////////////////////////////////////////////////////////////// IF empty(aControls[10]:editbuffer()) select 0 netuse(cCompanyDir+"ACOMP","Comp") Comp->(DbGotop()) aControls[10]:setdata(Comp->Company) aControls[11]:setdata(Comp->Address1) aControls[12]:setdata(Comp->Address2) aControls[13]:setdata(Comp->City) aControls[14]:setdata(Comp->State) aControls[15]:setdata(Comp->Zip) select Vendors DO WHILE !Vendors->(DbrLock()) ENDDO FOR i:= 10 TO 15 aControls[i]:getdata() NEXT i Vendors->(DbrUnlock()) NetClose("Comp") ENDIF ////////////////////////////////////////////////////////////// The Error Log is: ERROR LOG of "C:\maniacc\MANIACC.EXE" Date: 08/16/2010 15:15:20 Xbase++ version : Xbase++ (R) Version 1.90.331 Operating system : Windows 06.00 Build 06002 Service Pack 2 Alias of WorkArea 3 is VENDORS --- File = J:\maniacc\YOUNGDALE\APVENDOR.DBF ------------------------------------------------------------------------------ oError:operation : <SSTATE>:=<CA ...> oError:description : Lock is required for this operation oError:args : -> VALTYPE: C VALUE: CA oError:cargo : NIL oError:canDefault : N oError:canRetry : N oError:canSubstitute: Y oError:filename : oError:genCode : 76 oError:osCode : 0 oError:severity : 2 oError:subCode : 8043 oError:subSystem : BASE oError:thread : 1 oError:tries : 0 ------------------------------------------------------------------------------ CALLSTACK: ------------------------------------------------------------------------------ Called from (B)FIELDWBLOCK(0) Called from VENDORS(428) Called from (B)MENUCREATE(326) Called from MAIN(613) ============================================================================== So why should :getdata() not recognize that the record has been locked? "replace" works but ":getdata()" fails btw: each of the sle's have their datalink defined using FIELDWBLOCK() | |
Raymond | Re: :getdata() bug on Tue, 17 Aug 2010 21:02:00 +0200 Joe Carrick a formulé ce mardi : > I use the following code which does not result in an error: > > ////////////////////////////////////////////////////////////// > IF empty(aControls[10]:editbuffer()) > select 0 > netuse(cCompanyDir+"ACOMP","Comp") > Comp->(DbGotop()) > aControls[10]:setdata(Comp->Company) > aControls[11]:setdata(Comp->Address1) > aControls[12]:setdata(Comp->Address2) > aControls[13]:setdata(Comp->City) > aControls[14]:setdata(Comp->State) > aControls[15]:setdata(Comp->Zip) > select Vendors > DO WHILE !Vendors->(DbrLock()) > ENDDO > replace Vendors->sCompany with Comp->Company,; > Vendors->sAddress1 with Comp->Address1,; > Vendors->sAddress2 with Comp->Address2,; > Vendors->sCity with Comp->City,; > Vendors->sState with Comp->State,; > Vendors->sZip with Comp->Zip > Vendors->(DbrUnlock()) > NetClose("Comp") > ENDIF > ////////////////////////////////////////////////////////////// > > but if I use the following I get a runtime error: > > ////////////////////////////////////////////////////////////// > IF empty(aControls[10]:editbuffer()) > select 0 > netuse(cCompanyDir+"ACOMP","Comp") > Comp->(DbGotop()) > aControls[10]:setdata(Comp->Company) > aControls[11]:setdata(Comp->Address1) > aControls[12]:setdata(Comp->Address2) > aControls[13]:setdata(Comp->City) > aControls[14]:setdata(Comp->State) > aControls[15]:setdata(Comp->Zip) > select Vendors > DO WHILE !Vendors->(DbrLock()) > ENDDO > FOR i:= 10 TO 15 > aControls[i]:getdata() > NEXT i > Vendors->(DbrUnlock()) > NetClose("Comp") > ENDIF > ////////////////////////////////////////////////////////////// > > The Error Log is: > > ERROR LOG of "C:\maniacc\MANIACC.EXE" Date: 08/16/2010 15:15:20 > > Xbase++ version : Xbase++ (R) Version 1.90.331 > Operating system : Windows 06.00 Build 06002 Service Pack 2 > Alias of WorkArea 3 is VENDORS --- File = J:\maniacc\YOUNGDALE\APVENDOR.DBF > ------------------------------------------------------------------------------ > oError:operation : <SSTATE>:=<CA ...> > oError:description : Lock is required for this operation > oError:args : > -> VALTYPE: C VALUE: CA > oError:cargo : NIL > oError:canDefault : N > oError:canRetry : N > oError:canSubstitute: Y > oError:filename : > oError:genCode : 76 > oError:osCode : 0 > oError:severity : 2 > oError:subCode : 8043 > oError:subSystem : BASE > oError:thread : 1 > oError:tries : 0 > ------------------------------------------------------------------------------ > CALLSTACK: > ------------------------------------------------------------------------------ > Called from (B)FIELDWBLOCK(0) > Called from VENDORS(428) > Called from (B)MENUCREATE(326) > Called from MAIN(613) > ============================================================================== > > So why should :getdata() not recognize that the record has been locked? > "replace" works but ":getdata()" fails > > btw: each of the sle's have their datalink defined using FIELDWBLOCK() Hello Joe, I am sorry but I can't help you much but the way you retrieve the data to store in the table are completely different. REPLACE works because you use Comp->Company for example therefore you are accessing the comp table to fill the vendor's one. Try to change this code: > replace Vendors->sCompany with Comp->Company,; by this one: > replace Vendors->sCompany with aControls[10]:getdata() ,; If you come to the same problem, then the error is probably in your SLE definition. Best regards, Raymond Amicalement, Raymond http://www.mouches.org http://www.cpmn.be | |
Joe Carrick | Re: :getdata() bug on Tue, 17 Aug 2010 12:59:49 -0700 Hi Raymond, Actually in both cases I set the data in the Sle exactly the same way. note that :setdata() assigns a value to the Sle :getdata() retrieves the value of the Sle and assigns it to the database field. The 1st example simply updates the values in Vendors with the contents of the EditBuffers. The 2nd example attempts to set the values by using the :getdata() method which essentially does a straight assignment. ie: STATE := "CA" - Still at a loss to explain the "lock" problem. > > Hello Joe, > I am sorry but I can't help you much but the way you retrieve the data > to store in the table are completely different. > > REPLACE works because you use Comp->Company for example therefore you > are accessing the comp table to fill the vendor's one. > > Try to change this code: >> replace Vendors->sCompany with Comp->Company,; > > by this one: >> replace Vendors->sCompany with aControls[10]:getdata() ,; > > If you come to the same problem, then the error is probably in your SLE > definition. > > Best regards, > Raymond > | |
Raymond | Re: :getdata() bug on Tue, 17 Aug 2010 22:35:48 +0200 Hi Joe, I know that. I just wanted to point out that saying that "replace" was working while getdata() was not is not valid. In your first example you use an external field to fill the record. In the second you use getdata(). So my proposal was to change the first example and to use getdata() there too to see if it also breaks: >> 1) replace Vendors->sCompany with aControls[10]:getdata() >> 2) Vendors->sCompany := aControls[10]:getdata() another test is: >> 3) Vendors->sCompany := Comp->Company instead of: >> replace Vendors->sCompany with Comp->Company and I am sure that example 1 and 2 will also break. This said, I cannot see why there is a problem with the locking. You could also try with RLock() instead of dbRLock() Joe Carrick vient de nous annoncer : > Hi Raymond, > > Actually in both cases I set the data in the Sle exactly the same way. > note that > :setdata() assigns a value to the Sle > :getdata() retrieves the value of the Sle and assigns it to the database > field. > > The 1st example simply updates the values in Vendors with the contents of the > EditBuffers. > > The 2nd example attempts to set the values by using the :getdata() method > which essentially does a straight assignment. ie: STATE := "CA" > > - Still at a loss to explain the "lock" problem. > >> >> Hello Joe, >> I am sorry but I can't help you much but the way you retrieve the data >> to store in the table are completely different. >> >> REPLACE works because you use Comp->Company for example therefore you >> are accessing the comp table to fill the vendor's one. >> >> Try to change this code: >>> replace Vendors->sCompany with Comp->Company,; >> >> by this one: >>> replace Vendors->sCompany with aControls[10]:getdata() ,; >> >> If you come to the same problem, then the error is probably in your SLE >> definition. >> >> Best regards, >> Raymond Amicalement, Raymond http://www.mouches.org http://www.cpmn.be | |
AUGE_OHR | Re: :getdata() bug on Wed, 18 Aug 2010 00:31:15 +0200 hi, > netuse(cCompanyDir+"ACOMP","Comp") ... > aControls[i]:getdata() ... > btw: each of the sle's have their datalink defined using FIELDWBLOCK() perhaps you did "too much" ... did you use a ALIAS() ? look again to Helpfile ... LOCAL bBlock1 := FieldWBlock( "Name", 1 ) ... ? Eval( bBlock1 ) Laufzeitfehler: Codeblock ist an Workarea Nr. 1 gebunden Error : Codeblock bound to Workarea No. 1 greetings by OHR Jimmy |