Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Insert Error
Message
De
19/12/2005 06:59:24
 
 
À
19/12/2005 04:20:48
Information générale
Forum:
Visual FoxPro
Catégorie:
Client/serveur
Titre:
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Database:
MySQL
Divers
Thread ID:
01079054
Message ID:
01079122
Vues:
16
>Fabio,
>
>Thankyou for your help. But I have thousands of lines of code that are accessing the data with SQL pass through, so in the short term it isn't an option to change to using a CursorAdapter, in the long term I would hope to do this.
>
>I assumed that VFP9 would be backward compatible with VFP6, but it doesn't seem like it is.
>
>Regards
>Darren Donald
>
>

Darren,

I doesn't suggest to use CursorAdapter, it is a example only.

You have a wrong code, then if it work on vfp6 then vfp6 is wrong here.

Fix your code with a single "UpdatableFieldList" setting and it should work.

Fabio

>
>>>Hi Fabio,
>>>
>>>I am actually not sending an append blank. I have just done a small test and am having the same problem. I created a mysql table called salman with two fields
>>>
>>>sls_no Integer (Primary Key)
>>>sls_nm Varchar 45
>>>
>>>If I create a VFP cursor
>>>
>>>
>>>lcSQL="select * from salman"
>>>lnSelect=sqlexecute(lnConn,lcSQL,"cuSalman")
>>>
>>>
>>>Then get it ready for updates
>>>
>>>
>>>CURSORSETPROP("Tables","salman","cuSalman")
>>>CURSORSETPROP("UpdateName","sls_no salman.sls_no","cuSalman")
>>>CURSORSETPROP("UpdateName","sls_nm salman.sls_nm","cuSalman")
>>>CURSORSETPROP("KeyFieldList","sls_no","cuSalman")
>>>CURSORSETPROP("UpdatableFieldList","sls_no,sls_nm","cuSalman")
>>>CURSORSETPROP("SendUpdates",.t.,"cuSalman")
>>>
>>>
>>>If I then browse this cursor and add a record like sls_no=50 and sls_nm="Test Salesman", and then committ the record (move off the record), if their isn't a record with sls_no=0, it will committ the new record but change the sls_no to zero (but doesn't display the change to zero in VFP, subsequent queries shows the sls_no as zero). If I then try to add another record like sls_no=100 and sls_nm="Test Salesman Again" I will get an error that I violated the primary key of the table, because VFP is trying to committ sls_no again as zero. If I just enter a new sls_no field I get the error "Cannot insert an empty row from a view or CursorAdapter into base table(s)", although the sls_nm field can accept null values in mySQL.
>>>
>>>Can someone see where I am going wrong with this? In VFP6 this just works, I never have any trouble with it. Is their something new in VFP9 that I am failng to address.
>>>
>>>Any help appreciated.
>>>
>>>
>>>Regards
>>>Darren Donald
>>>
>>>
>>>
>>
>>this is wrong ( VFP allow short property name ( a bad programming style ))
>>
>>CURSORSETPROP("UpdateName","sls_no salman.sls_no","cuSalman")
>>CURSORSETPROP("UpdateName","sls_nm salman.sls_nm","cuSalman") && this remove the previous
>>
>>
>>correct is
>>
>>CURSORSETPROP("UpdateNameList","sls_no salman.sls_no,sls_nm salman.sls_nm")
>>
>>
>>try:
>>
>>CREATE CURSOR salman (sls_no I , sls_nm V(45))
>>
>>ca=CREATEOBJECT("cursoradapter")
>>ca.datasourcetype = "NATIVE"
>>ca.alias = "cuSalman"
>>CA.SELECTCMD = "select * from salman"
>>CA.CURSORFILL
>>CA.CURSORDETACH
>>RELEASE CA
>>SELECT cuSalman
>>CURSORSETPROP("Tables","salman")
>>CURSORSETPROP("KeyFieldList","sls_no")
>>CURSORSETPROP("UpdateNameList","sls_no salman.sls_no,sls_nm salman.sls_nm")
>>CURSORSETPROP("UpdatableFieldList","sls_no,sls_nm")
>>CURSORSETPROP("SendUpdates",.t.)
>>
>>BROWSE
>>
>>
>>
>>clear
>>CLOSE TABLES ALL
>>CREATE CURSOR salman (sls_no I , sls_nm V(45))
>>
>>ca=CREATEOBJECT("cursoradapter")
>>ca.datasourcetype = "NATIVE"
>>ca.alias = "cuSalman"
>>CA.SELECTCMD = "select * from salman"
>>CA.CURSORFILL
>>CA.CURSORDETACH
>>RELEASE CA
>>SELECT cuSalman
>>CURSORSETPROP("T","salman")
>>CURSORSETPROP("K","sls_no")
>>CURSORSETPROP("UpdateN","sls_no salman.sls_no,sls_nm salman.sls_nm")
>>CURSORSETPROP("Updata","sls_no,sls_nm")
>>CURSORSETPROP("Se",.t.)
>>
>>
>>APPEND BLANK
>>replace sls_no  WITH RAND()*10000
>>GO 1 && send
>>	
>>? salman.sls_no
>>
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform