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!

LAN access of dbf 1

Status
Not open for further replies.

Mandy_crw

Programmer
Jul 23, 2020
585
PH
Hi everyone... almost done with my project with LAN access, I can open the app in three client computers, i can add, edit and preview record in the three client computers, my only problem is, when i add a record in client cmputer 1, i cant see the added record ín the server and to other cmputers not unless i restart the appication... Please help.... Thanks....
 
What are you doing to add and save a new record?

To close a table can help to commit the changes, more seldom a FLUSH works (see the help topic on FLUSH).


But to get the idea on multi user (client) database access there is a good topic in the help topic
Using Visual Foxpro -> Working With Data -> Programming For Shared Access
(Or simply search Shared Access in the help search)

It teaches you to use Buffering and/or Locking data.

Chriss
 
Yes Chris, Im adding and saving a new record...
 
Well, with what code?

If you just bind a table to a grid and don't use code for saving the record may stay locally cached only.
As restarting helps can be a case of buffering and you might not even be aware you use it by the data environment.

Do you restart other clients to let them see the record?
How do you fetch the ddata? If you SELECT * FROM TABLE you get all data of a table but don't get updates unless you rredo the query, for example.

I suggest yyou read the help topic to dive deeper into this topic, it's surely not the easiest one to cover correctly at first try.


Chriss
 
Hi Chriss... sorry for the super late reply... I've been into a lot of errands....

this is my load routine

PROCEDURE Load()

SET PATH TO c:
SET TALK OFF
SET BELL OFF
SET CENTURY ON
SET CONFIRM OFF
SET SAFETY OFF
SET ECHO OFF
SET ESCAPE OFF
SET AUTOSAVE ON

SELECT 0
USE transaction shared ALIAS trans ORDER idnum

SELECT 0
USE smsrec shared ALIAS rek ORDER idnum

SELECT 0
USE sms shared ALIAS tsulat ORDER idnum

SET relation TO idnum INTO trans

SELECT idnum, ALLTRIM(sname) + ", " + ALLTRIM(fname) FROM tsulat ORDER BY sname, fname INTO CURSOR csrdemo

ENDPROC


and this is for my other procedures...

PROCEDURE CmdAdd.Click()

SELECT tsulat

SEEK this.parent.text1.value

IF NOT FOUND()

IF FLOCK()

APPEND blank

REPLACE tsulat.idnum WITH this.Parent.text1.value
REPLACE tsulat.fname WITH this.Parent.text2.value
REPLACE tsulat.sname WITH this.Parent.text3.value
REPLACE tsulat.mobile WITH this.Parent.text4.value

UNLOCK IN TSULAT
ELSE
WAIT WINDOW 'Unable to open MAIN Table; try again later!' NOWAIT
ENDIF

ELSE
MESSAGEBOX("Duplicate IDNumber! Cannot Continue",0+64,"Student's Account")
RETURN
ENDIF

SELECT idnum, ALLTRIM(sname) + ", " + ALLTRIM(fname) FROM tsulat ORDER BY sname, fname INTO CURSOR csrdemo READWRITE

MESSAGEBOX("Record appended to Main Table",0+64,"Student's Record!")

This.Parent.text1.value = " "
This.Parent.text2.value = " "
this.Parent.text3.value = " "
this.Parent.text4.value = " "

ENDPROC

am i getting it correctly? thanks
 
Mandy,

I see Chris is helping you with this, so I won't interfere.

But regarding your user message: 'Unable to open MAIN Table; try again later!'.

If your system is aimed at non-technical end-users, may I suggest an improvement to that wording. Most users won't know what a "main table" is or what the implications are for being unable to open it - nor is there any reason why they should know.

I suggest instead something like: "Another user is editing this data. Please try again later."

Seeing an error message always invokes a certain amount of stress, so anything you can do to make the user more comfortable is worthwhile.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Hello Mandy,

well, this works, but has nothing to do with multiuser access other than using FLOCK to be sure you can write to the table. It's not necessary to make such a lock to insert data. But you make a typical error, you APPEND BLANK and then use a series of replaces. All this can be done with one INSERT (SQL). Or you insert this into a buffered view and then a TABLEUPDATE() can not only insert a single record but all changes done in a local workarea, which can be deletions, new records and updated/changed data.

As I said there is a whole topic about Programming For Shared Access and the minimum to learn is about MULTLOCKS, buffering and locking, pessimisitic vs optimistic, TABLEUPDATE() and its implications and requirements. It's too much for a single answer or thread or FAQ, it means learning a whole chapter. The least thing you get from it is better understanding errors and what they mean and what reasons they could have. And that's not something anyone can teach you in a simple forum discussion, so take it serious to learn the whole help section about programming for shared access.

Chriss
 
Thanks Mike, I'll do that.... very helpful.... Ok Chris... thank you so much..... i will.... Thank you Mike and Chris....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top