Hi,

I want to insert a record into the database and i want only unique values in my database using ado.

every thing is going fine but i am unable to restrict the duplicate values.How should i write code to avoid duplicate values in my database.

where URL is the field and it should be unique.



My code is :

Private Sub AddRecord()
On Error GoTo ErrorHandler
Dim SavedFlg As Boolean

' Add a new record using the recordset object
' Could be done using the connection object
SavedFlg = True
mRs.Open "SELECT * FROM csecurity", mCn, adOpenKeyset, adLockOptimistic
With mRs
If SavedFlg = True Then
mCn.BeginTrans
.AddNew
.Fields("WINDOWTITLE").Value = TxtIETitle.Text
.Fields("URL").Value = TxtIEUrl.Text
.Fields("ADATE").Value = Now
mRs.Update
mCn.CommitTrans
End If
' After updating the recordset, we need to refresh it, and then move to the
' end to get the newest record. We can then retrieve the new record's id

.Requery
.MoveLast
.Close
End With

ErrorHandler:

If Err <> 0 Then
MsgBox Err.Source & "-->" & Err.Description, , "Error"
End If
End Sub

any one can help me..

Thanks for advance