Click here to Skip to main content
13,507,984 members
Rate this:
Please Sign up or sign in to vote.
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 20-Feb-13 0:39am
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

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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 ..


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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.180417.1 | Last Updated 22 Feb 2013
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100