* Create the Connection and RecordSet objects and open the Connection. > >local loConn as ADODB.Connection, ; > loRS as ADODB.Recordset, ; > loProperty as ADODB.Property >loConn = createobject('ADODB.Connection') >loRS = createobject('ADODB.Recordset') >loConn.ConnectionString = 'Provider=vfpoledb;Data Source=' + ; > addbs(_samples) + 'Data\Testdata.DBC' >loConn.Open() >loRS.ActiveConnection = loConn >loRS.CursorType = 3 && adOpenStatic >loRS.LockType = 3 && adLockOptimistic > >* Open the table as a server-side cursor (or comment out the first two lines >* and uncomment the next two for a cursor-side cursor; however, in that case, >* the loRS.Update() fails after the AddNew). > >loRS.CursorLocation = 1 && adUseServer >loRS.Open('use Customer') >*loRS.CursorLocation = 3 && adUseServer >*loRS.Open('select * from Customer') > >* Change the company name for the first record. > >loRS.MoveFirst() >lcCompany = loRS.Fields('Company').Value >loRS.Fields('Company').Value = 'test me' >loRS.Update() >loRS.AddNew() >loRS.Fields('Cust_ID').Value = 'NEWREC' >loRS.Fields('Company').Value = 'New Record' >loRS.Update() > >* Browse the table to see the change. > >open database addbs(_samples) + 'Data\Testdata.DBC' >use customer >browse >use > >* Change the changed record back, delete the new one, and display the table >* again. > >loRS.MoveFirst() >loRS.Fields('Company').Value = lcCompany >loRS.Update() >loRS.MoveLast() >loRS.Delete() >loRS.Update() >use customer >browse > >* Clean up and exit. > >loRS.Close() >loConn.Close() >use customer exclusive >pack >useNote the comment about Update failing after AddNew with a client-side cursor. I'm sure there's some way around that; I just haven't dug far enough into it.