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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stoping concurency of values in the database

Status
Not open for further replies.

progfox

Programmer
Jun 15, 2003
43
0
0
IN
Dear Sir,
Can u tell me that how can I prevent entering duplicate values while entering records in the grid.

Well I am cheking the duplicacy of records in lost focust of textbox control, and its not at all able to find any such duplicate records.

If possible pls provide me the code for it.


Regards

Chandan
 
progfox

If possible pls provide me the code for it.

Can you provide us with the code you are using, so we can determine where the problem is?


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Hi Gagnon,
Thanks for showing interest in the query. Well here is the respective code that I have written in the lost focus of a text control and by writing so I am generating an unique id.

SELECT group FROM .\data\garmenttypes INTO CURSOR xsisc WHERE ALLTRIM(garment)=ALLTRIM(thisform.grid1.column1.combo1.value)
SELECT colorcode FROM .\data\colormaster INTO CURSOR xcolr WHERE ALLTRIM(colorname)=ALLTRIM(thisform.grid1.column4.combo1.value)
SELECT prototypid FROM .\data\collection1 INTO CURSOR xcheck READWRITE
IF thisform.optiongroup1.option1.Value=1
prototype=ALLTRIM(thisform.text1.value)+ALLTRIM(xsisc.group)+alltrim(STR(thisform.grid1.column5.text1.value))+ALLTRIM(STR(thisform.grid1.COlumn6.TExt1.Value))+ALLTRIM(STR(thisform.grid1.column7.text1.value))+ALLTRIM(xcolr.colorcode)+ALLTRIM(SUBSTR(thisform.grid1.column2.combo1.Value,0))+"SHC"
SELECT xcheck
GO TOP
LOCATE FOR xcheck.prototypid=ALLTRIM(prototype)
IF found()
MESSAGEBOX("found")
SELECT MAX(VAL(SUBSTR(prototypid,7,1))) as num FROM COLLECTION1 WHERE LEFT(prototypid,6)=LEFT(prototype,7) INTO CURSOR xchk1 READWRITE
prototype1=ALLTRIM(thisform.text1.value)+ALLTRIM(xsisc.group)+ALLTRIM(str(xchk1.num))+alltrim(STR(thisform.grid1.column5.text1.value))+ALLTRIM(STR(thisform.grid1.column6.text1.value))+ALLTRIM(STR(thisform.grid1.column7.text1.value))+ALLTRIM(xcolr.colorcode)+ALLTRIM(SUBSTR(thisform.grid1.column2.combo1.Value,1))+"SHC"
thisform.grid1.column10.text1.Value=ALLTRIM(prototype1)
thisform.grid1.column3.text1.Value=ALLTRIM(thisform.text1.value)+ALLTRIM(STR(thisform.xitm+1))
ELSE
MESSAGEBOX("not found")
thisform.grid1.column10.text1.Value=ALLTRIM(prototype)
thisform.grid1.column3.text1.Value=ALLTRIM(thisform.text1.value)+ALLTRIM(STR(thisform.xitm+1))
ENDIF
ENDIF
 

Have you tried

Code:
LOCATE FOR ALLTRIM(xcheck.prototypid)=ALLTRIM(prototype)

It might just be a case of blank spaces vs alltrim.


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Hello Chandan.

>> Can u tell me that how can I prevent entering duplicate values while entering records in the grid. <<

If this is a multi-user application, the only sure fire way to prevent duplicates is to set up a candidate key on the field(s) in which you want to prevent duplicate values.

The reason is that, no matter how thoroughly you check for duplicates when you are entering the data, some one else on the system can save a duplicate value after your check and before your save.

So, if you set up a candidate key, all you have to do is check for Uniqueness of index "name" is violated (Error 1884) and take the appropriate action.



Marcia G. Akins
 
Marcia & Mike,
Thanks for ur replies. BUt Sir I want to prevent the concurrency as well as want to add A, B, C... like that in the concurrent data.I have given the code for that. I have taken the data in a cursor and while I ma auto generating the code based on few parameter(variable prototype) I want to search wher tehr it exists or not. If exists the add either 1,2,3.. or A,B,C.. like that at the end of the variable. If I am doing that first time it works because the cursor is having the data, but at the run time I am adding the same data then it doesn't work.So sir please help me. Just get me out of the situation, I deadly need it.

Thanx & Regards

Chandan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top