Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

URGENT!Local View does not update data into table located on SERVER

Status
Not open for further replies.

IvySoe

Programmer
Apr 9, 2015
24
SG
Please anybody help!.
My Foxpro version is visual foxpro 7. I have 2 problems regarding local view.
1 . In the FORM data environment, I use parent table and child table view display in grid. When data enter and save, only parent table update , child view did not update child table. But in form, the child records are still reflect in grid.

2. Error : 2005
Error loading file- record number 6. Cnocls1<or one of its members>. ControlSource: Variable 'ctr2_gln' is not found
Line of code with error : Select * from ap_pkg!ctr2_fil where ctr2_fil.ctr2_trncd= trncd and ctr2_fil.ctr2_docno = docno order by ctr2_fil.ctr2_trncd,ctr2_fil.ctr2_docno,ctr2_fil.ctr2_line into cursor Viewcalv51

there error only happen while functioning in the morning and happened in afternoon. There are many possible factors like server update, virus, change some server setting i guess. server also restarted and still cannot solve.

My setting is as follow. I have foxpro DBC and application exe on server (windows server 2008 r2 with SP1). folder structure is 'Company/APPKG/DBF/'. under DBF folder , stores database.dbc and .dbf files. users use application from workstation with shortcut configure as 'Target: serverlocation/ap.exe', start in : serverlocation/company/APPKG/DBF


 
Are you sure you understand the error?
record number 6 is really meaning record number 6 of the form and not line number 6 of some method.
> ControlSource: Variable 'ctr2_gln' is not found
Some control defined in reord 6 of the scx is having the controlsource 'ctr2_gln', but that variable doesn't exist.

Error 2005 description even says you set some property to an illegal value, eg your control has Controlsource: [=ctr2_gln ] in the property window, which would mean it isn't bound to the variable ctr2_gln, but the value of ctr2_gln will be set as the controlsource. And if ctr2_gln is a number, that would mean you try to set controlsource to a numeric value, which is an illegal value for controlsources.

In regard to views updating data, look into the view designer, is the view designed to be updatable?

And last not least on the whole setup: Runnning an exe from a server has been judged a bad practice for many years. It's unlikely your problems are related to that, though.

Bye, Olaf.
 
1. Table has no record.
2. In the form data environment, i bind table1(can be said parent), and table2view (can be said child). table2view bind to grid with buffer mode 5. Each grid column control source can browse view fields from properties windows and bind each view field with each column.
2. It was working until yesterday. and no changes in code and db tables.

Following is my two table that cause error 2005 (error occur at form load event, no code written in form load event)
my table structure is
table1 : tran_code,doc_no, doc_line, doc_grpLine,supplier_cd, doc_date,desc, .....so on.
index1 - tran_code + doc_no
index2 - suplier_cd + doc_date + tran_code + doc_no

table2 : tbl2_trncd,tbl2_docno, tbl2_line, tbl2_gln,tbl2_amt,tbl2_acccode, tbl2_acc_desc.... so on.
index1 tbl2_trncd+tbl2_docno+STR(tbl2_line,3)
index2 tbl2_trncd+tbl2_docno
index3 tbl2_trncd+tbl2_docno+STR(tbl2_line,3)+STR(tbl2_gln,3)

I set relationship table 1 index1 and table2 index1
local view is created for table2 -> tbl2_view.
options from view designer Filter : tbl2_trncd and tbl2_docno
Order by : tbl2_trncd,tbl2_docno,tbl2_line,tbl2_gln
group by : tbl2_trncd,tbl2_docno,tbl2_line,tbl2_gln
Update Criteria : Table -> table2, ticked PK key options -> tbl2_trncd,tbl2_docno,tbl2_line,tbl2_gln, ticked all columns,Send Sql updates ->ticked. Update using -> SQL update



 
*****This error 2005 causes only on server.
The form can be loaded and new records can be saved successfully without any error on workstation, local pc where database and exe are on same pc.
 
Well, you can't put a dbc or dbfs on the server and expect the data environment of a form to be rerouted there automatically.

Bye, Olaf.
 
Dear Olaf,
It works that way before..... would you give me some suggestion pls ?
 
Hi Ivy,
You have to make sure that the tables/views are loaded correctly. Please have a look at the code below or at the below mentioned KB-article - you'll have to place it in the BeforeOpenTables Event of the DataEnvironment.

Code:
* [URL unfurl="true"]http://support.microsoft.com/kb/128996/en-us[/URL]
LOCAL lcDataPath, lnStartPos, i, lcObjClass, lcDataName, lcNewDataPath, lcObjName
LOCAL loCursor as Cursor

lcDataPath = "c:\YourDataFolder"

IF !EMPTY(lcDataPath)
   = AMEMBERS( laCursors, THISFORM.DATAENVIRONMENT, 1)
   = ASORT( laCursors, 2)

   lnStartPos = ASCAN( laCursors, "Object", -1, -1, 2, 15)
   IF NOT EMPTY(lnStartPos)
      FOR i = lnStartPos TO ALEN(laCursors, 1)
         IF laCursors[ i, 2] = "Object"
            lcObjClass = "ThisForm.DataEnvironment." + laCursors[ i, 1] + ".class"
            IF EVAL( lcObjClass) = "Cursor"
               lcObjName = "ThisForm.DataEnvironment." + laCursors[ i, 1] + ".Database"
               lcDataName = EVAL(lcObjName)
               lcNewDataPath = ALLTRIM( lcDataPath) + ALLTRIM( SUBSTR( lcDataName, RAT( "\", lcDataName) + 1))
               loCursor = EVAL( "ThisForm.DataEnvironment." + laCursors[ i, 1])
               IF NOT EMPTY(loCursor.Database)
                  loCursor.DATABASE = lcNewDataPath
               ELSE
                  loCursor.CursorSource = ADDBS(ALLTRIM(lcDataPath)) + JUSTFNAME(loCursor.CursorSource)
               ENDIF
            ENDIF
         ELSE
            EXIT
         ENDIF
      ENDFOR
   ENDIF
ENDIF
RETURN

hth

MK
 
An exe, which has forms pointing to local data in it's dataenvironments will pick up the local data, unless you
1. delete or rename the local data folder
2. in your start code have a SET PATH to the server database.

And if you read any config data, look into that.

Bye, Olaf.
 
Thank you so much guy!!!!
It was a great help!
The problem was solved with the code by mjcmkrsr.

FYI: I set db path on main program with global variable as lcDataPath = "..\appkg\dbf"
It has been working all the time since before yesterday afternoon.
And the problem only cause on server to client. On local machine, still working.

To fix this, i used the code provided by mjcmkrsr to set cursor path lcDataPath = "..\appkg\dbf\" ****adding "\" to my db path
Missing '\' caused cannot load the view on server to client.
Thank you again for sharing!!!!!

 
>On local machine, still working
Because on local machine you have the local database and your dataenvironment looks there.

Bye, Olaf.
 
But, I still couldn't find out the reason of the error.

My software folder structure : I have 3 modules , each with individual database and exe . For example, AP (account payable), AR (account receivable), GL (General Ledger).
Each module folder structure is : serverpath\companyname\appkg\dbf\database.dbc , serverpath\companyname\arpkg\dbf\database.dbc, serverpath\companyname\glpkg\dbf\database.dbc
exe files are : serverpath\ap.exe, serverpath\ar.exe, serverpath\gl.exe
on user local machine : create shortcut to exe with target "serverpath\companyname\appkg"

Database tables are same format and template , for example , AP and AR , both has customer and supplier table with same column counts and data types, indexes with same column counts and view with same setting.
AP : customer table = AR : supplier table.
AP : purchase invoice table = AR : sales invoice table.

Program/coding : for each AP, AR, GL
in the main program, set global variables and assign folder names , set path to db and screens and make all pre settings.
in individual forms, use the global variable to access table and db.

*Even though all AP,AR,GL exe has the same coding and setting, only AP and GL got the error. AR is OK.
I have no clue yet. I am still trying to look into PC setting, network setting and server setting to know the cause of the error.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top