Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 9 of 9 total
Thread problem with win2000 server/client
Mon, Feb 8 2010 5:27 AMPermanent Link

"Carlos"
DBISAM 3:30
Server: Win 2000 server - client: win2000 professional

Master/detail table: two client insert a new master record; then insert some
detail record.

There are known problems with insertion at the same time, of a new record
from two clients ?
Or problem with LockTable ?

Thanks

Carlos

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Sometime I found two identical  NewCod
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

 Dati.Utente.Open;
 Dati.Utente.LockTable;
 Dati.Utente.Refresh;
 NewCod:=Copy(IntToStr(StrToint(Dati.Utente.FieldByName('LAST_CODE').AsString)+1000001),2,6);
// last code used like 00001, 00002, ....

 if Trim(NewCod)='' then begin // error
    beep;
    ShowMessage('***   ERROR  ***');
    Dati.Utente.UnlockTable;
    Dati.Utente.Close;
    exit;
 end;

 Dati.Utente.Edit;
 Dati.Utente.FieldByName('ULT_PREV').AsString:=NewCod;
 Dati.Utente.Post;
 Dati.Utente.UnlockTable;
 Dati.Utente.Close;

 Dati.Preventivi.Append;
 Dati.Preventivi.Edit;
 Dati.Preventivi.FieldByName('CODCLI').AsString     :=CustomerCode;
 Dati.Preventivi.FieldByName('PREVENTIVO').AsString :=NewCod;
 Dati.Preventivi.FieldByName('DATAPREV').AsDateTime :=Date;
 Dati.Preventivi.Post;

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



Mon, Feb 8 2010 8:44 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Carlos,

<< There are known problems with insertion at the same time, of a new record
from two clients ? Or problem with LockTable ? >>

No, there shouldn't be.  What error are you seeing ?

--
Tim Young
Elevate Software
www.elevatesoft.com

Mon, Feb 8 2010 9:04 AMPermanent Link

"Carlos"

"Tim Young [Elevate Software]" <timyoung@elevatesoft.com> ha scritto nel
messaggio news:18FD8A9F-1EFC-4426-9939-F9C41C0C6148@news.elevatesoft.com...
> Carlos,
>
> << There are known problems with insertion at the same time, of a new
> record from two clients ? Or problem with LockTable ? >>
>
> No, there shouldn't be.  What error are you seeing ?
>
> --
> Tim Young
> Elevate Software
> www.elevatesoft.com
>

In the working area of our customer
*sometime*   I get two identical   NewCod  (Win2000 server + Win2000 pro)

In our area (win2003 server + XPpro) i never get duplicate NewCod.

A BIG mistery !!

Thank you for your patience

Carlos

Mon, Feb 8 2010 9:10 AMPermanent Link

"Raul"
Carlos,

How do you actually update the 'LAST_CODE' field ? The code you showed in
original post retrieves it but does not update it as far as I can tell.

Raul


"Carlos" <carlos@gmail.com> wrote in message
news:B9C16CAA-B3BB-457C-B1A2-E293106E74BA@news.elevatesoft.com...
>
> "Tim Young [Elevate Software]" <timyoung@elevatesoft.com> ha scritto nel
> messaggio
> news:18FD8A9F-1EFC-4426-9939-F9C41C0C6148@news.elevatesoft.com...
>> Carlos,
>>
>> << There are known problems with insertion at the same time, of a new
>> record from two clients ? Or problem with LockTable ? >>
>>
>> No, there shouldn't be.  What error are you seeing ?
>>
>> --
>> Tim Young
>> Elevate Software
>> www.elevatesoft.com
>>
>
> In the working area of our customer
> *sometime*   I get two identical   NewCod  (Win2000 server + Win2000 pro)
>
> In our area (win2003 server + XPpro) i never get duplicate NewCod.
>
> A BIG mistery !!
>
> Thank you for your patience
>
> Carlos
>
>
> __________ Information from ESET NOD32 Antivirus, version of virus
> signature database 4848 (20100208) __________
>
> The message was checked by ESET NOD32 Antivirus.
>
> http://www.eset.com
>
>
>

__________ Information from ESET NOD32 Antivirus, version of virus signature database 4848 (20100208) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com


Mon, Feb 8 2010 9:23 AMPermanent Link

"Carlos"

"Raul" <raul@raul.ca> ha scritto nel messaggio
news:8D966309-E531-454E-B105-26A31298A0F5@news.elevatesoft.com...
> Carlos,
>
> How do you actually update the 'LAST_CODE' field ? The code you showed in
> original post retrieves it but does not update it as far as I can tell.
>
> Raul
>


Yes
sorry but I get a mistake in copy/paste the code

Here the right code:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

 Dati.Utente.Open;
 Dati.Utente.LockTable;
 Dati.Utente.Refresh;
 NewCod:=Copy(IntToStr(StrToint(Dati.Utente.FieldByName('LAST_CODE').AsString)+1000001),2,6);
// last code used like 00001, 00002, ....

 if Trim(NewCod)='' then begin // error
    beep;
    ShowMessage('***   ERROR  ***');
    Dati.Utente.UnlockTable;
    Dati.Utente.Close;
    exit;
 end;

 Dati.Utente.Edit;
 Dati.Utente.FieldByName('LAST_CODE').AsString:=NewCod;
 Dati.Utente.Post;
 Dati.Utente.UnlockTable;
 Dati.Utente.Close;

 Dati.Preventivi.Append;
 Dati.Preventivi.Edit;
 Dati.Preventivi.FieldByName('CODCLI').AsString     :=CustomerCode;
 Dati.Preventivi.FieldByName('PREVENTIVO').AsString :=NewCod;
 Dati.Preventivi.FieldByName('DATAPREV').AsDateTime :=Date;
 Dati.Preventivi.Post;

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Mon, Feb 8 2010 9:54 AMPermanent Link

"Robert"

"Carlos" <carlos@gmail.com> wrote in message
news:D34DDC90-0024-4F34-8182-642984D1ABE2@news.elevatesoft.com...
>

Is it possible you are ignoring an exception, something like that? The code
looks pretty simple and straightforward (not sure why you open and close
utente table, but that should not matter).

If another station is doing an update, then you should get an exception on
either one of these spots

>
>  Dati.Utente.Edit;  <<<<pessimistic
>  Dati.Utente.FieldByName('LAST_CODE').AsString:=NewCod;
>  Dati.Utente.Post; <<< optimistic

I'm not sure what the locktable is doing here, maybe that's the problem. Tim
would know.

Robert

Tue, Feb 9 2010 11:42 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Carlos,

<< In the working area of our customer *sometime*   I get two identical
NewCod  (Win2000 server + Win2000 pro) >>

That's because your code is not correct.  In-between the time of the
retrieval of the last code and the next Edit, another client could have
retrieved the same code and beat the current session to the next Edit.

What you need is this, only this (pessimistic record locking):

 Dati.Utente.Edit;
 NewCod:=Copy(IntToStr(StrToint(Dati.Utente.FieldByName('LAST_CODE').AsString)+1000001),2,6);
 Dati.Utente.FieldByName('LAST_CODE').AsString:=NewCod;
 Dati.Utente.Post;

 Dati.Preventivi.Append;
 Dati.Preventivi.Edit;
 Dati.Preventivi.FieldByName('CODCLI').AsString     :=CustomerCode;
 Dati.Preventivi.FieldByName('PREVENTIVO').AsString :=NewCod;
 Dati.Preventivi.FieldByName('DATAPREV').AsDateTime :=Date;
 Dati.Preventivi.Post;

If you still get a duplicate code, then there's something wrong with Windows
2000.  Look here for some possible issues:

http://www.elevatesoft.com/bulletin_4.htm
http://www.elevatesoft.com/bulletin_5.htm

--
Tim Young
Elevate Software
www.elevatesoft.com

Wed, Feb 10 2010 3:38 AMPermanent Link

"Carlos"
> What you need is this, only this (pessimistic record locking):
>
>  Dati.Utente.Edit;
>
> NewCod:=Copy(IntToStr(StrToint(Dati.Utente.FieldByName('LAST_CODE').AsString)+1000001),2,6);
>  Dati.Utente.FieldByName('LAST_CODE').AsString:=NewCod;
>  Dati.Utente.Post;
>
>  Dati.Preventivi.Append;
>  Dati.Preventivi.Edit;
>  Dati.Preventivi.FieldByName('CODCLI').AsString     :=CustomerCode;
>  Dati.Preventivi.FieldByName('PREVENTIVO').AsString :=NewCod;
>  Dati.Preventivi.FieldByName('DATAPREV').AsDateTime :=Date;
>  Dati.Preventivi.Post;
>

I understand
Tomorrow afternoon I'm going to do a test session at the customer site and
let you know.
Thanks again

Carlos

Fri, Feb 12 2010 5:57 AMPermanent Link

"Carlos"
Problem solved updating from Win2000 SP3 to SP4
Both old and new version works corretly.


Thanks again

Carlos


>
> I understand
> Tomorrow afternoon I'm going to do a test session at the customer site and
> let you know.
> Thanks again
>
> Carlos
>

Image