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:48:16
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
20/11/2001 12:38:20
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00583878
Message ID:
00584058
Views:
72
Hi Doug,
This is VFP code. From VFP I can run easily too. It's when I do it in ASP.
Client and Server side tested :(
Cetin

>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
Ç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
Reply
Map
View

Click here to load this message in the networking platform