Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to stop entering data  RSS feed

 
adeeb alexander
Ranch Hand
Posts: 268
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have created an interface which accepts the details of a person and stores it in database it also stores the id. Now what i need is if the details are entered more than 3 times then i should get a message that "U cant enter any more". So please some one give me an idea please its urgent.
 
Rob Spoor
Sheriff
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Entered where? In the database? Or in the user interface?

If it is in the database, you first have to perform a query to find out how many records already match your criteria:

If that returns a number too high (like 3 already) then deny the entering.
[ June 06, 2008: Message edited by: Rob Prime ]
 
Campbell Ritchie
Sheriff
Posts: 53750
127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by adeeb alexander:
please its urgent.
Ease Up. And I see Rob has beaten me to it with a useful answer.
 
adeeb alexander
Ranch Hand
Posts: 268
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ya i want to enter data into database with the help of gui
and as you said that i have to write a query but how to write it. How can we compare the rows. Can you please tell me
 
Rob Spoor
Sheriff
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That depends what fields you have and which ones are relevant for the uniqueness.

Suppose you have a first and last name, and these can only occur 3 times. Then the query would be

with Rob and Prime coming from your user interface. I would suggest using PreparedStatement though as it will prevent users entering bad values and thereby corrupting your datamodel. If you want more info on that, search for SQL injection on Google etc.

The return value of that query will have to be checked against the maximum number allowed.
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This has been cross-posted in the same cryptic fashion at the Sun Java tutorials.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!