Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: SQLVB.NET
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
Comments
CHill60 at 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 at 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
good
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 ..
 
Rgds,
Nitesh..
  Permalink  

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

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 800
1 OriginalGriff 503
2 Abhinav S 253
3 thatraja 245
4 Emre Ataseven 200
0 Sergey Alexandrovich Kryukov 8,282
1 OriginalGriff 4,750
2 Peter Leow 3,784
3 Maciej Los 3,515
4 Er. Puneet Goel 3,107


Advertise | Privacy | Mobile
Web02 | 2.8.140415.2 | Last Updated 22 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid