Avoid Dulpicacy while entering Data in SQL db using VB6 as front end
Iam beginner in Vb & SQL. I am entering data like MemberName(txtMemberName.text) in sql database through VB6 front end form. I can enter same data in this field. Can any body help me in avoiding the duplicacy of the data. Following is my code on Save button :- Private Sub btnSave_Click() If (validate()) Then Adodc1.Recordset.Fields("MembershipID") = Val(Trim(txtMemberID.Text)) Adodc1.Recordset.Fields("MemberName") = Trim(txtMemberName.Text) Adodc1.Recordset.Fields("Address") = txtAddress.Text Adodc1.Recordset.Fields("ContactNo") = Val(txtContactNo.Text) Adodc1.Recordset.Fields("Height") = Val(txtHeight.Text) Adodc1.Recordset.Fields("Gender") = cmbGender.Text Adodc1.Recordset.Fields("JoiningDate") = CDate(Trim(txtJoiningDate.Text)) Adodc1.Recordset.Fields("DateOfBirth") = CDate(Trim(txtDateOfBirth.Text)) If Option1.Value = True Then Adodc1.Recordset.Fields("IsTrainerRequired") = 1 Else Adodc1.Recordset.Fields("IsTrainerRequired") = 0 End If Adodc1.Recordset.Update MsgBox "Member Successfully Added", vbOKOnly, "Member Registration" Adodc1.Recordset.MoveLast btnAdd.Enabled = True btnSave.Enabled = False btnClear.Enabled = False Else MsgBox "Please Enter and Save Appropriate Values", vbApplicationModal End If 'ClearAll End Sub

Software/Hardware used:
ASKED: March 11, 2012  3:00 PM
UPDATED: April 11, 2012  2:09 PM

Answer Wiki:
hi, this is simple think, use the primary key or unique key constraints for which column you want avoid duplicate values.
Last Wiki Answer Submitted:  April 11, 2012  2:09 pm  by  Gowriking   65 pts.
All Answer Wiki Contributors:  Gowriking   65 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

Take a look at This similar question.

Feel free to post any additional question/doubts you may encounter.

 63,580 pts.