Information générale
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
CursorAdaptor and Microsoft dBase ODBC driver
Greetings.
I am using VFP 8.0 SP1 and having a problem getting a cursoradaptor to update a dBase III file using the Microsoft dBase ODBC driver. Cursorfill()will provide me a with a populated cursor but upon changing a field value and issuing Tableupdate(), the error message "Connectivity error: Unable to retrieve specific error information. Driver is probably out of resources" pops up. This occurs in WinXP SP1 and in Win2k SP4.
The interesting thing is that using a remote view works just fine as does SPT, so the driver works OK. In fact, I create a public var connection handle using SQLSTRINGCONNECT() and use it with the cursoradaptor. The update fails. I can plug the same SQL update statement used by the cursoradaptor (obtained via Cursoradaptor AfterUpdate()) into a SQLEXEC() call along with the public connection handle and the update succeeds.
Using the Visual Foxpro ODBC driver, the cursoradaptor will update the table correctly but of course the dbase indexes are not updated.
This appears to be a VFP 8 bug in the way the cursoradaptor communicates with the dBase ODBC driver. Has anyone else encountered this problem or am I not seeing something obvious? I would like to get feedback before I post this is in the UT VFP bug thread.
This is the prg I used to test this;
*******************
CLEAR
SET EXCLUSIVE OFF
CLOSE DATABASES ALL
SET MULTILOCKS ON
PUBLIC nhnd, xupdatecmd, loCursor, lcUpdateCmd
nhnd=SQLSTRINGCONNECT("Driver={Microsoft dBase Driver (*.dbf)};DriverID=21;FIL=dBase III;DefaultDir=c:\service;Dbq=c:\service;EXCLUSIVE=False;")
loCursor=CREATEOBJECT('CA')
* Load loCursor with the data specified in SelectCmd and display error message if error occurs.
IF !loCursor.CursorFill()
=AERROR(lar)
MESSAGEBOX(lar[2])
ENDIF
GO TOP
REPLACE freq WITH "a"
lsuccess=TABLEUPDATE(1,.T.,locursor.alias)
* lsuccess is False
lsuccess=SQLEXEC(nhnd,lcUpdateCmd)
* lsuccess is 1 - subsequent browse shows data updated correctly in dBase III bldgserv table
********************************
DEFINE CLASS CA AS CursorAdapter
Alias = 'test1'
SelectCmd = 'select * from bldgserv where bldgid=2544'
Tables = 'bldgserv'
KeyFieldList = "bldgid, servcode"
UpdatableFieldList = "bldgid, servcode, freq"
UpdateNameList = "bldgid bldgserv.bldgid,freq bldgserv.freq servcode bldgserv.servcode"
WhereType= 3 && Key and modified
PROCEDURE init
WITH THIS
.DataSourceType = 'ODBC'
.DataSource=nhnd
.SendUpdates=.T.
.AllowUpdate=.T.
.AllowInsert=.T.
.AllowDelete=.T.
.UpdateType=1
ENDWITH
ENDPROC
PROCEDURE AfterUpdate
LPARAMETERS cFldState, lForce, nUpdateType, UpdateInsertCmd, DeleteCmd, lResult
lcUpdateCmd=UpdateInsertCmd
ENDPROC
*******************
TIA.
Patrick
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement