Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Insert Error
Message
From
19/12/2005 02:51:11
 
 
To
19/12/2005 02:29:47
General information
Forum:
Visual FoxPro
Category:
Client/server
Title:
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Database:
MySQL
Miscellaneous
Thread ID:
01079054
Message ID:
01079091
Views:
53
>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 
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform