Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
CursorAdapter SQLCE Updating
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01314075
Message ID:
01314114
Views:
20
>I am attemping to use MS SQL CE 3.5 datastore in a VFP app. I am getting an error when I attempt to update data. AERROR shows: 1420 "OLE object is invalid or corrupted".
>
>I have not used ADO with CA before. Any idea what I am doing wrong?
>
>This is the update statement generated: UPDATE Orders SET SHIP_NAME=?cursor1.ship_name WHERE ORDER_ID=?OLDVAL('order_id','cursor1')
>
>
>
>x = CREATEOBJECT("test")
>REPLACE ship_name WITH ''
>? TABLEUPDATE(2,.T.,"CURSOR1")
>
>
>DEFINE CLASS test AS cursoradapter
>
>  SelectCmd= "select * from Orders"
>  CursorSchema= "ORDER_ID I, CUSTOMER_ID C(5), EMPLOYEE_ID I, SHIP_NAME C(40), SHIP_ADDRESS C(60), SHIP_CITY C(15), SHIP_REGION C(15), SHIP_POSTAL_CODE C(10), SHIP_COUNTRY C(15), SHIP_VIA I, ORDER_DATE T, REQUIRED_DATE T, SHIPPED_DATE T, FREIGHT Y"
>  Alias = "cursor1"
>  DataSourceType = "ADO"
>  InsertCmdDataSourceType = "ADO"
>  UpdateCmdDataSourceType = "ADO"
>  DeleteCmdDataSourceType = "ADO"
>  Flags = 0
>  KeyFieldList= "ORDER_ID"
>  Tables= "Orders"
>  UpdatableFieldList= "ORDER_ID, CUSTOMER_ID, EMPLOYEE_ID, SHIP_NAME, SHIP_ADDRESS, SHIP_CITY, SHIP_REGION, SHIP_POSTAL_CODE, SHIP_COUNTRY, SHIP_VIA, ORDER_DATE,"+;
>                       REQUIRED_DATE, SHIPPED_DATE, FREIGHT"
>
>  ors = .F.
>  oconn = .F.
>  Name = "test"
>
>
>   PROCEDURE Init()
>	
>    local llReturn
>    set multilocks on
>    llReturn = dodefault()
>
>      TEXT TO this.UpdateNameList NOSHOW
>	  ORDER_ID Orders.ORDER_ID, CUSTOMER_ID Orders.CUSTOMER_ID, EMPLOYEE_ID Orders.EMPLOYEE_ID, SHIP_NAME Orders.SHIP_NAME, SHIP_ADDRESS Orders.SHIP_ADDRESS,
>         SHIP_CITY Orders.SHIP_CITY, SHIP_REGION Orders.SHIP_REGION, SHIP_POSTAL_CODE Orders.SHIP_POSTAL_CODE, SHIP_COUNTRY Orders.SHIP_COUNTRY,
>         SHIP_VIA Orders.SHIP_VIA, ORDER_DATE Orders.ORDER_DATE, REQUIRED_DATE Orders.REQUIRED_DATE, SHIPPED_DATE Orders.SHIPPED_DATE, FREIGHT Orders.FREIGHT
>	  ENDTEXT
>
>    This.DataSource = this.oRS
>    This.UpdateCmdDataSource = this.oRS
>    This.oRS.ActiveConnection = this.oConn
>    IF this.CursorFill(.T.) = .F.
>    	MESSAGEBOX(MESSAGE())
>    ENDIF
>    return llReturn
>  ENDPROC
>
>
>
>
>  PROCEDURE ors_access()
>    LOCAL loRS as ADODB.RecordSet
>    IF VARTYPE(this.oRS)<>"O" THEN
>    this.oRS = NULL
>    loRS = CREATEOBJECT("ADODB.Recordset")
>    IF VARTYPE(loRS)="O" THEN
>    loRS.CursorType= 3  && adOpenStatic
>    loRS.CursorLocation = 3  && adUseClient
>    loRS.LockType= 3  && adLockOptimistic
>    this.oRS = loRS
>    ENDIF
>    ENDIF
>    RETURN this.oRS
>  ENDPROC
>
>  PROCEDURE oconn_access()
>    LOCAL loConn as ADODB.Connection
>    IF VARTYPE(this.oConn)<>"O" THEN
>    	this.oConn = NULL
>   		 loConn = CREATEOBJECT("ADODB.Connection")
>	    IF VARTYPE(loConn)="O" THEN
>		    loConn.ConnectionString = 'PROVIDER=Microsoft.SQLSERVER.CE.OLEDB.3.5;Data Source = "C:\temp\Northwind.sdf"'
>		    loConn.OPEN()
>		    this.oConn = loConn
>	    ENDIF
>    ENDIF
>    RETURN this.oConn
>  ENDPROC
>
>  PROCEDURE AfterUpdate()
>    LPARAMETERS cFldState, lForce, nUpdateType, cUpdateInsertCmd, cDeleteCmd, lResult
>    _cliptext = cUpdateInsertCmd
>  ENDPROC
>
>
>ENDDEFINE &&test
>
>
>
>
>
>
Check UpdateCmdDataSource in help:

"ADO"  UpdateCmdDataSource must be set to a valid ADO Command object.
       The ActiveConnection property of the ADO Command object must be set to a valid and open ADO Connection object.

       Visual FoxPro sets the CommandText property of the ADO Command object to the value of the CursorAdapter UpdateCmd property.
       Visual FoxPro parses the command for  parameters, creates parameter values if found, and sets them in the Command object.

       The update operation occurs as:
       CursorAdapter.UpdateCmdDataSource.Execute()
 
      For more information about using an ADO RecordSet, automatic updating, and generating SQL commands automatically, see Data Access Management Using CursorAdapters
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform