Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SPT error when setting CURSORSETPROP
Message
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
SPT error when setting CURSORSETPROP
Divers
Thread ID:
00787810
Message ID:
00787810
Vues:
74
I have the following SPT code and I want my table to be updateable. When I run the code I keep getting an error on
CURSORSETPROP( "TABLES", "ITCR42KDAT.UDFields", lcCursor )
It keeps saying that "No table is open in the current work area".


Here is my code to for connections and update
WITH thisform
	LOCAL a,g,x,lcUpdFields,lcUpdNames
	IF ISNULL(.oCon)
		.oCon = NEWOBJECT('ConMgr','conmgr.prg')
	ENDIF 
	.nCon = .oCon.OpenConn('itc_H_drive')
	IF .nCon < 1
		MESSAGEBOX('connection failed')
		RETURN .f.
	ENDIF 
*	MESSAGEBOX('connection successful!!!')
	SQLSETPROP(.nCon,"Asynchronous",.f.)
	lnRes = SQLSETPROP( .nCon, "DispWarnings", .F. )
	g = '444-44-4444'
	lcSql = " Select *" ;
	      + "  FROM UDFields UD" ;
	      + "  where UD.SSNo = '"+g+"'"

	lcCursor = SYS(2015)
	IF USED(lcCursor)
		TABLEREVERT(.t.,lcCursor)
	ENDIF 
	lnRes = SQLEXEC( .nCon, lcSql, "lcCursor" )
	IF lnRes > 0		
		x = RECCOUNT()
		SELECT lcCursor
		AFIELDS(fieldinfo)
		****Define fields to be updated
		lcUpdFields = ''
		lcUpdNames = ''
		FOR i = 1 TO ALEN(fieldinfo,1)
			IF i < ALEN(fieldinfo,1)
				lcUpdFields = lcUpdFields + fieldinfo(i,1) + ","
				lcUpdNames = lcUpdNames + fieldinfo(i,1)+ " " + "UDFields." + fieldinfo(i,1) + ","
			ELSE
				lcUpdFields = lcUpdFields + fieldinfo(i,1)
				lcUpdNames = lcUpdNames + fieldinfo(i,1)+ " " + "UDFields." + fieldinfo(i,1)		
			ENDIF 
		ENDFOR 
	    *** Set Tables property (Table for INSERT, UPDATE or DELETE)
	    CURSORSETPROP( "TABLES", "ITCR42KDAT.UDFields", lcCursor )
	    *** Key Field(Key field for WHERE clause)
	    CURSORSETPROP( "KEYFIELDLIST", "idnumber", lcCursor )
	    *** Updateable Field List (Fields which are updatable)
	    CURSORSETPROP( "UPDATABLEFIELDLIST", lcUpdFields, lcCursor )
	    *** UpdateNameList (Back-end table name for each cursor field )
	    CURSORSETPROP( "UPDATENAMELIST", lcUpdNames ,lcCursor )
	    *** Set Where Type and Send update flag
	    CURSORSETPROP( "WHERETYPE", 1, lcCursor )
	    CURSORSETPROP( "SENDUPDATES", .T., lcCursor )
	    *** Also set the Buffer/Locking Mode to Table/Optimistic
	    CURSORSETPROP( "Buffering", 5, lcCursor )
	    *** Update the display
		BROWSE	
		lnRes = .oCon.CloseConn(.nCon)
	ELSE 
		MESSAGEBOX('SPT query failed to connect',0,'')
	ENDIF 
ENDWITH
What am I doing wrong? The "lcCursor" does have data in it when I browse and I have selected the cursor also right before I build the update field list.

Thanks
Nick Patel
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform