Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
GetPrimaryKey not firing when access VFP datasource
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
COMCodebook
Titre:
GetPrimaryKey not firing when access VFP datasource
Divers
Thread ID:
00727500
Message ID:
00727500
Vues:
36
I downloaded the COMCodeBook controls and used the wizard to set up a test application against my VFP MasterWebSystem database. I created a few Get methods and those worked well. So I decided to test the add COM code. I tried testing several ways but they all did not work correctly.

First my test database already had a Stored Procedure called getkey() that generates PrimaryKeys for me by passing the table I deal with. So for my test table (user) I have a field called usrkey with a default value of 'getkey("user")'. But when I used COMCodeBook to add a new record the call 'lnUsrKey = oRMControl.save( cXMLValidation )' the value returned from the Save method is 0. So my default PrimaryKey method GetKey was not even being called and the record generated had a 0 PrimaryKey.

My second test was to remove the GetKey default from the UsrKey field and try it again. And the same result happened. I get a record added with 0 as the primarykey.

My third test was to create my own GetPrimaryKey method in my Class UserDataSource that was built by the Wizard and placed in my MWSDataSource.prg. I created the GetPrimaryKey and just told it to 'lcPrimaryKey = 1999'. But to my surprise the method was not even called when I ran the Save Method. I still recieved 0 as my PrimaryKey and a record was added with 0 as the primarykey. So upon further investigation I found the reason my GetPrimaryKey method was not executed was the line 'IF EMPTY( toADORS.Fields( THIS.cTableID ).UnderlyingValue ) ' in the AssignPrimaryKeys method in cdatasources.prg prevents the call, because the UnderlyingValue is NULL and EMPTY returns false on a NULL value, thus the code 'lnRetVal = THIS.GetPrimaryKey( @lcPrimaryKey, toADO )' was never being executed.

So my basic question (other than the bug noted) is does COMCodeBook automatically generate PrimaryKeys for me even if I have a default PrimaryKey generator inside the Database Stored Procedures and called by the default value of the PrimaryKey field of the table? Does COMCodeBook want me to remove the default PrimaryKey value called in my Database? Does COMCodeBook want me to create my own GetPrimaryKey code?

Any help from COMCodeBook authors or those using COMCodeBook would be helpfull.

TIA
Bret Hobbs

"We'd have been called juvenile delinquents only our neighborhood couldn't afford a sociologist." Bob Hope
Répondre
Fil
Voir

Click here to load this message in the networking platform