Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Updating CursorAdapter w/Free Tables
Message
From
12/10/2006 21:40:56
 
 
To
12/10/2006 02:39:13
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01161323
Message ID:
01161631
Views:
29
>>All,
>>
>>Our company is in the process of trying to migrate old legacy data over to SQL Server. My Idea was to try and use cursor adapters--a very wonderful invention. Because these tables are used in a plethora of different applications, I can't just DTS them into SQL Server. I want to create the cursor adapter to initially pull from old FoxPro DOS table structures. When we have converted all the applications, then switch the DataSource and DataSourceType to go to SQL. My problem revolves around trying to update one of these Free tables in a CA. It runs CursorFill just fine, takes the insertion of data w/o a problem, but my TableUpdate() returns a .F. I'm at a loss and was hoping I could get some assistance on this.
>>
>>Here's the code:
>>
>>
>>PUBLIC cacs as CursorAdapter
>>caCS = CREATEOBJECT('cursoradapter')
>>SET MULTILOCKS ON
>>
>>WITH cacs
>>  .Name = 'caCACS'
>>  .Alias = 'vCACS'
>>  .AllowInsert=.T.
>>  .AllowUpdate=.T.
>>  .BufferModeOverride= 5
>>  .CursorSchema = ;
>>    [CUSTSERID I,  FR C(6) DEFAULT '', ] + ;
>>    [GRADE C(2) DEFAULT '', LOTCONTROL C(9) DEFAULT '', ] + ;
>>    [MHEAT C(4) DEFAULT '', PHEATSFX C(2)   DEFAULT '', ] + ;
>>    [PROD_HEAT C(6) DEFAULT '']
>>  .DataSourceType = 'ODBC'
>>  .DATASOURCE= SQLSTRINGCONNECT([DSN=Visual FoxPro Tables;UID=;PWD=;] + ;
>>    [SourceDB=G:\SOFTWARE\SERIAL\;SourceType=DBF;Exclusive=No;] + ;
>>    [BackgroundFetch=Yes;Collate=Machine;])
>>  .KeyFieldList = 'CustSerID'
>>  .NoData = .T.
>>  .Prepared = .F.
>>  .SelectCmd = [select custserid, fr, grade, lotcontrol, mheat,]+ ;
>>    [ prod_heat, pheatsfx from custser WHERE custserid = ?gnCustSerID]
>>  .Tables = 'CustSer'
>>  .UpdatableFieldList = [CUSTSERID, FR, LOTCONTROL, PROD_HEAT, ] + ;
>>    [PHEATSFX, GRADE, MHEAT]
>>  .UpdateNameList =[CUSTSERID custser.custserid, FR custser.fr, ] + ;
>>    [LOTCONTROL custser.lotcontrol, PROD_HEAT custser.prod_heat, ] + ;
>>    [PHEATSFX custser.pheatsfx, GRADE custser.grade, MHEAT custser.mheat ]
>>  .UpdateType= 1
>>  .UseCursorSchema = .T.
>>  .SendUpdates = .T.
>>  .WhereType = 3
>>  ? .CursorFill(.T.,.T.)
>>ENDWITH
>>
>>BROWSE LAST NOWAIT
>>INSERT INTO vcacs (custserid, fr, lotcontrol, prod_heat, grade, mheat) ;
>>	 VALUES (3779862, '11181', 'ND23734', 'LC2631', 'SG', '6271')
>>
>>? TABLEUPDATE(1)	
>>
>>
>>TIA,
>
>Always check the result of TableUpdate:
>
>IF NOT TABLEUPDATE(1, .t., [vcacs])
>   AERROR(laError)
>   MessageBox(laError[1,2])
>ENDIF
>
Thanks for responding, Borislav.

Good point, and I have code like that in my application. In this case I put it in an abbreviated .prg to show my class and where the problem occurs. I've tried ADO and ODBC with the same results. A couple of things may not be clear. The CursorSchema only shows a few of the fields of the table. I have gone back and put all the fields into the CursorSchema as well as default values for each field. I've also added all fields to the SelectCmd with the same results. AERROR, BTW, says that one of the fields in the underlying table will not accept nulls. So the insert appears to be failing b/c one of the fields that I'm not assigning a value to thinks I'm trying to assign a null. Do you see anything that might cause the Insert to fail to the free table? Do you know of anything that limits the usage of free tables in CursorAdapters?
Duty is ours, the results are God's - John Quincy Adams
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform