Click here to Skip to main content
15,745,232 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have table that contain (id, name and date) and my concern is: how to prevent saving same id at the same date but only month and year..
I hope someone understand my question, sorry for my terrible explain.
Pankit Patel 22-May-15 2:45am    
did you mean that you have to prevent to store Same Id at the Same date...???
and what u want to say about "but only month and year"
DheeDika 22-May-15 7:48am    
I just want to exactly prevent store just by month and year(mm-yyyy) not by dd-mm-yyyy :)

1 solution

The id should be unique. So you need some logic for getting a unique id. An easy way is to store the last id value in a function and a request is adding 1 and stores it like that:

int getId()
 int last = IdFromStore();
 int id = last + 1;

 StoreId( id );

 return id;
Share this answer
DheeDika 22-May-15 7:48am    
Id alrready unique, gotta go try it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900