Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Updating through SPT
Message
From
08/08/2003 09:03:04
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Client/server
Miscellaneous
Thread ID:
00818150
Message ID:
00818164
Views:
20
This message has been marked as the solution to the initial question of the thread.
>Hi all, I want to update an access DB using SPT. I got the following code to connect to the DB.
>
>
>	Thisform.Connhandle=0
>	Thisform.Connhandle = SQLCONNECT("NominaPopular")
>	IF Thisform.ConnHandle>-1
>		nSucceded = SQLEXEC(Thisform.Connhandle,"Select * from tbNomina","NominaPopular")
>		IF nSucceded>-1
>			SetRemoteCursor("NominaPopular")
>		ELSE
>			Thisform.Mensajes("Could Not Connect To DB!",1)
>			IF Thisform.Mensajes("Do You Wish To Continue?",2)=NO
>				Thisform.NominaElectronica=.f.
>				Thisform.Release
>				RETURN 0
>			ENDIF
>		ENDIF
>
>
>
>And the following code to set the properties of the cursor
>
>FUNCTION SetRemoteCursor(cNombreCursor)
>	CURSORSETPROP("SendUpdates",.t.,cNombreCursor)
>	CURSORSETPROP("Buffering",5,cNombreCursor)
>	CURSORSETPROP("Tables",cNombreCursor,cNombreCursor)
>	CURSORSETPROP("KeyFieldList","fldCodigoEmpleado",cNombreCursor)
>	CURSORSETPROP("UpdatableFieldList","fldCodigoEmpleado,fldNumeroCta,fldMonto,fldTipoRegistro,fldNombreEmp",cNombreCursor)
>ENDFUNC
>
>
>The connection is working and retrieving the data but, when I issue the following test code, it doesn't update the remote table.
>
>
>SELECT NominaPopular
>APPEND BLANK
>replace fldCodigoEmpleado WITH "10000"
>replace fldmonto WITH 5000
>replace fldNumeroCta WITH "1234567890"
>replace fldNombreemp WITH "Someone's Name"
>
>IF !TABLEUPDATE(0,.f.,"NominaPopular")
>	WAIT WINDOW "NO SE pudo Actualiza La Tabla 1"
>	SQLROLLBACK(Thisform.Connhandle)
>	RETURN 0
>ELSE
>	IF SQLCOMMIT(Thisform.Connhandle)=-1
>		WAIT WINDOW "NO Se Pudo Actualizar La Tabla 2"
>	ELSE
>		WAIT WINDOW "Registro Actualizado"
>	ENDIF
>ENDIF
>
>
>
>What am I missing here???
>
>TIA,
>
>Enmanuel G.

You're missing UpdateNameList as I could see at first glance. ie:
SQLExec(lnHandle,'select * from dbo.authors','v_authors')
CursorSetProp('KeyFieldList','au_id','v_authors')
CursorSetProp('WhereType',1,'v_authors')
CursorSetProp('Tables','authors','v_authors')

CursorSetProp("UpdateNameList", ;
  "au_id    authors.au_id,"+;
  "au_lname authors.au_lname,"+;
  "au_fname authors.au_fname,"+;
  "contract authors.contract",'V_authors')

CursorSetProp('UpdatableFieldList','au_fname,au_lname,contract','v_authors')
CursorSetProp('SendUpdates',.T.,'v_authors')
CursorSetProp('Buffering',5,'v_authors')
In updatenamelist fields appear in pairs, on the left is your fieldname and on the right basetable's fieldname. ie:
SQLExec(lnHandle,'select FirstName as Fname, LastName as Lname'+;
' from ServerTable...', 'v_myview)

CursorSetProp("UpdateNameList", ;
  "Fname ServerTable.FirstName,"+;
  "Lname ServerTable.LastName",'V_myView')
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform