Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Has anyone used VFPOLEDB to update data ?
Message
From
20/11/2001 12:38:20
 
 
To
20/11/2001 09:08:22
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00583878
Message ID:
00584052
Views:
31
This message has been marked as a message which has helped to the initial question of the thread.
Hi Cetin.

>Using ODBC I can update data from ASP. But whenever I try to use VFPOLEDB instead I get :
>'Cannot update the cursor' && If used with 'insert into ...'
>or :
>'Recordset doesn't support update. ...' && If used Addnew and update.
>As if it's readonly (or does really provider doesn't support updates from ASP?). I couldn't find much documentation about VFPOLEDB.

This code works for me:
* 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
use
Note 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.

Doug
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform