Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Unable to update CA with C(10) binary field
Message
De
19/08/2005 08:46:01
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Network:
Windows XP
Database:
Visual FoxPro
Divers
Thread ID:
01042202
Message ID:
01042235
Vues:
20
>I take this code from another forum and tried to help the man that use it. Unfortunately I stick with it :o(
>Here the code:
>
>
>LOCAL oca AS CursorAdapter
>
>SET ASSERTS ON
>
>********************
>IF EMPTY(SYS(2000,"c:\test.dbf"))
>   CREATE TABLE c:\test.dbf (testval C(10) NOCPTRANS)
>   APPEND BLANK
>   USE
>endif
>set multilocks on
>oca=createobject("cursoradapter")
>oca.alias="catest"
>oca.buffermodeoverride=5
>oca.cursorschema="TESTVAL C(10)"
>oca.datasourcetype="ADO"
>*oca.mapbinary=.T.
>oca.selectcmd="Select * From test"
>oca.tables="test"
>oca.SendUpdates       = .t.
>oca.updatablefieldlist="TESTVAL"
>oca.updatenamelist="TESTVAL test.TESTVAL"
>oca.keyfieldlist="TESTVAL"
>
>loConnDataSource = createobject('ADODB.Connection')
>loConnDataSource.ConnectionString = [Provider=VFPOLEDB.1;Data Source=c:\test.DBF;Password="";Collating Sequence=MACHINE;]
>loConnDataSource.Open()
>oca.DataSource = createobject('ADODB.RecordSet')
>oca.DataSource.CursorLocation   = 3  && adUseClient
>oca.DataSource.LockType         = 3  && adLockOptimistic
>oca.DataSource.ActiveConnection = loConnDataSource
>oca.cursorfill(.t.)
>SELECT catest
>**INSERT INTO CaTest VALUES ("Test")
>***GO BOTTOM
>replace testval WITH TRANSFORM(RECNO())
>
>IF TABLEUPDATE(1)
>ELSE
>   ASSERT .f.
>   =AERROR(amessage)
>   =MESSAGEbox(amessage(2))
>ENDIF
>USE IN cATest
>
>This code always stops on ASSERT with "Microsoft Cursor Engine : Multiple-step operation generated errors. Check each status value."
>
>This code not works in VFP9 too. What I am missing? Generaly I use ODBC for my Cursor Adapters so I am not so familiar with ADO.
>
>I have the latest VFPOLEDB installed
>
>
>UPDATE: Sorry for stupid mistake in the Title, of course it is not a FILE it is a FIELD :o(

run this:
LOCAL oca AS CursorAdapter

CLEAR 
SET ASSERTS ON
CLOSE TABLES ALL

********************
CREATE TABLE c:\test.dbf FREE (testval C(10))	&& N,I,V,... all fails
   APPEND BLANK
   replace testval WITH '1234'
USE

set multilocks on
oca=createobject("cursoradapter")
OCA.BreakOnError = .T.
oca.datasourcetype="ADO"
oca.alias="catest"
* why the cursorSchema is necessary ?????????
oca.cursorschema="TESTVAL C(10)"

oca.selectcmd="Select * From C:\test.DBF" && FULL PATH change the error message
oca.tables="test"
oca.SendUpdates       = .t.
oca.updatablefieldlist="TESTVAL"
oca.updatenamelist="TESTVAL test.TESTVAL"
oca.keyfieldlist="TESTVAL"

loConnDataSource = createobject('ADODB.Connection')
loConnDataSource.ConnectionString = [Provider=VFPOLEDB.1;Data Source=c:\test.DBF;Password="";Collating Sequence=MACHINE;]
loConnDataSource.Open()
oca.DataSource = Createobject('ADODB.RecordSet')
oca.DataSource.CursorLocation   = 3  && adUseClient
oca.DataSource.LockType         = 3  && adLockOptimistic
oca.DataSource.ActiveConnection = loConnDataSource
IF oca.cursorfill(.t.)
	SELECT catest
*	APPEND BLANK
	replace testval WITH '1'
	IF NOT TABLEUPDATE(1)
	   =AERROR(amessage)
		? "Error   ",amessage(1) , " !!!!!!! On HELP The message is XML Parse Error "
		? "Message ",amessage(2)
	ENDIF
	=TABLEREVERT(.T.)
ELSE
	   IF AERROR(amessage)>0
		? "Error   ",amessage(1)
		? "Message ",amessage(2)
	  ENDIF 
ENDIF
OCA.CursorDetach 
CLEAR ALL
It probably misses something.
Certainly the management of the errors is inaccurate rather.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform