|
-
Apr 22nd, 2006, 02:35 PM
#1
Thread Starter
Fanatic Member
avoid duplication in SQL table
hi
i have a form in which there is a filelistbox.
when the user clicks on the command Display,the filelistbox displays filenames present in a specific directory entered by the user
spath=Trim(txtpath)
File1.path=spath
if the filelistbox contains 10 filenames,when the user clicks on OK,
it will create 10 records in a table Article
Private Sub cmdOK_Click()
Rs1.Open"Select*from Article",SIC,adOpenStatic,adLockOptimistic
For i=0 to File1.listCount-1
Rs1.AddNew
Rs1!Source=Trim(txtsource)
Rs1!CompleteFile=File1.List(i)
Rs1!Flag=0(Flag is of int type)
Rs1.Update
Rs1.close
My problem is that if after adding the records corresponding to the list of filenames if the user enters by mistake the same path another time and clicks on Ok
,so in the Article table there will be duplication.how to avoid that if the user enters the same path twice or more to not add records to the Article table
thanks
-
Apr 22nd, 2006, 03:26 PM
#2
PowerPoster
Re: avoid duplication in SQL table
SELECT DISTINCT.......
Distinct does not give you dupes of records if i am not mistaken.
-
Apr 22nd, 2006, 03:50 PM
#3
Re: avoid duplication in SQL table
Just set the Path field as non-duplicable (Indexed as "Yes (No Duplicates)" in Access - if you're creating the table outside of Access, how you set this depends on how you're creating the table). Then adding a duplicate will raise an error, which you can trap.
Braille, your method will work for selects, but I think what engnouna is asking for is a method to keep duplicate records from being saved to the database in the first place.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|