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!

### Multi User Share Single Database 3

Status
Not open for further replies.

irfanhabib

Programmer
Feb 17, 2016
16
PK
Dear All Expert -

i like foxpro and presently i worked in visual foxpro , i have no idea
regarding form base programming , my all coding in prg file. ( Client.Prg )

presently i face problem , i have one(01) database
and i required multi user shared my database.

My Coding In Prg File
=====================

Set talk off
set echo off
set safe off
clear all
clear

Sele A
use counterfile
inde on counter to cnt
set orde to tag cn1
go bott
A=0
GO BOTT
A=COUNTER+1

SELE B
USE CLIENT
INDE ON CLIENTNAME TO CL1
SET ORDE TO TAG CL1
SCAT MEMV BLANK

@ 2,20 SAY 'Client Id : -'
@ 2,35 SAY ALLT(STR(A))

@ 4,20 SAY 'Cliennt Name ' Get M.CLIENTNAME
READ

Problem
=======

This is possible multiuser share above database on realtime, if multi user exceute same program on same
time , client id field automatically sense and display unique number and if any user exit without saving
remaing user clientid counter automatically refresh according to current numeric value.

I am very thankful quick and kind response.

very best regards
irfan habib
 
Welcome to the forum, Irfan.

You seem to be asking two different things. You say you "have no idea regarding form base programming". And the the code you posted confirms that. But your question is not at all relevant to forms. You are asking about how to deal with unique IDs in a multi-user environment.

For that second question, I advise you to use the Integer (Autoinc) data type for your IDs. That way, the management of multi-user collisions will be handled for you. But before you do that, you also need to learn about buffering, file and record locking, and multi-user processing in general. That's too big a subject for a simple forum question, so I suggest you spend some time reading the Help file on those topics. Then come back when you have some specific questions.

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Along with what Mike said, may I point out something that will be part of what you learn as you work with FoxPro more and more. You cannot index a table that is opened up by more than one user because creating an index on a table requires EXCLUSIVE access to a file. You would get an error message if you tried to index a table without the file being opened exclusively. In a multi-user environment, you would need to have EXCLUSIVE be set to OFF (SET EXCLUSIVE OFF).

Visual FoxPro is a completely different way of thinking compared to the DOS version of FoxPro. You'll need to get a good book on Visual FoxPro. From my own experience, Tamar Granor (along with Ed Roche) has a few books out that would be good choices. The one I used was "The Hacker's Guide to Visual FoxPro". They are likely other books that others may recommend for you.

For example, in Visual FoxPro, forms are their own entity just like everything else in object oriented programming (OOP). The form can have a Default Datasession or a Private Datasession. Just understanding that one concept is the first step in how you think of forms. Depending on that setting the form must or may have its own SET settings. Here's a list I have from a Visual FoxPro framework that I use:

* Here is a list of the SET commands that
* are scoped to private data sessions.
* This means that
* 1) changes made to them in a form with
* a private data session are not carried over
* to the default data session
* 2) these SETtings are defaulted from VFP
* defaults, *NOT* from any settings established
* in the current Default data session.

* NOTE THESE ARE THE VISUAL FOXPRO DEFAULT SETTINGS, NOT THE SETTINGS I USE.

* SET ANSI OFF
* SET AUTOSAVE OFF
* SET BLOCKSIZE TO 64
* SET CARRY OFF
* SET CENTURY OFF
* SET COLLATE TO "MACHINE"
* SET CONFIRM OFF
* SET CURRENCY TO
* SET DATABASE TO
* SET DATE TO AMERICAN
* SET DECIMALS TO 2
* SET DELETED OFF
* SET DELIMITERS OFF
* SET EXACT OFF
* SET EXCLUSIVE ON
* SET FIELDS TO
* SET FIXED OFF
* SET LOCK OFF
* SET MARK TO
* SET MEMOWIDTH TO 50
* SET MULTILOCK OFF
* SET NEAR OFF
* SET NULL OFF
* SET POINT TO
* SET REFRESH TO 0,5
* SET REPROCESS TO 0
* SET SAFETY ON
* SET SEPARATOR TO
* SET TALK ON
* SET UNIQUE ON
* SET VARCHARMAPPING OFF

In my forms I have various SET settings coded in the Load() method of all of my forms. Some of them are:
SET TALK OFF
SET ECHO OFF
SET SAFETY OFF
SET EXCLUSIVE OFF
SET CENTURY OFF
SET EXACT OFF
SET CONFIRM ON

There are others... this is what I can think of off the top of my head.

And... because of the concept of "inheritance" I have a "parent class" (a top-level form) that has these settings in it and then I create forms as a subclass of off that parent form (class). That means I only have to code these values in the top-level class (form) and all the forms I create based on that parent class will have these values set already.

Lots to learn. it is fun. OOP is so much better!

Bill
 
Have you looked at 'Programming for shared access' in the help file?

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
I am going to recommend that you spend some time looking over the free tutorial videos at:

You can either view the videos on-line or download them to view at another time.

Once you have a basic understanding of working with Visual Foxpro I am sure that things will begin to make sense.

However if you have additional questions, please feel free to come back and ask specific questions.
Keep in mind that there may be multiple ways to approach any specific issue.
We will most likely not just "give you the code", but we will try to help you understand so that you can develop your own code.

Good Luck,
JRB-Bldr
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top