Click here to Skip to main content
15,897,518 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I have a Table field that is name ID and the ID's are 1,2,3 (Auto Implemented)
another table field is named DocType and its data DOc1 Doc2 Doc3, so here's the problem:

I saved Doc1 and Creates an ID i.e. 1, same as for Doc2 and Doc3
but then I saved another data with an ID 4, but the data's name is Doc1

now, when I retrieve a data using ID 1 it Retrieves Doc1, same as for Doc2 and Doc3 but when I retrieve ID 4 it retrieves the Doc1 (the First Doc1 I saved, i has a data and time so i know which was first)

I need to know how to create a unique ID number so even if I save it with the same name but with a different date i know which came first and which I saved recently.
Posted
Comments
CHill60 20-Feb-13 6:45am    
I have severe doubts that if you search for ID=4 that it returns the row for which ID=1. Try using the Improve Question to post the SQL query you are using for the retrieve
Mike Meinz 20-Feb-13 9:23am    
An IsIdentity column is guaranteed unique.
An IsIdentity column's contents is chronologically ascending numeric values.

You get the best help here if you isolate the problem area of your code and show the problem code and data structure with enough background information for us to fully comprehend the problem.

1 solution

Use primary key which will act as unique index and it automatically created indexes on the field where you are creating index . Its you post your whole structure so that i can elaborate it more with codes .. But simple logic is to create either indexes on fields or else creating primary key constraint so that it wont even allow the user to insert duplicates ..

Rgds,
Nitesh..
 
Share this answer
 

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