Avoid duplicate entry in database through Visual Basic 2005

10 pts.
Tags:
Software Management
SQL 2005
SQL Server 2005
VB 2005
Visual Basic
Visual Basic 2005
I have made a program in VB 2005 with SQL2005 as back end. In the data base there are three fields which are unique id of a person. I want to display "Already Exist" message box when i enter an already existing id. matching all three fields and not allow duplicate entry.

Software/Hardware used:
Visual basic with SQL2005 as back end[Br _extended="true" /> At the same time I want the data to be displayed in one report Can anyone tell me what codes should be used for this.

Answer Wiki

Thanks. We'll let you know when a new response is added.

To avoid duplicates, you could create a primary key (or a unique index) on those 3 fields, and create a T-SQL stored procedure to perform the insert inside a <a href=”http://msdn.microsoft.com/en-us/library/ms175976(SQL.90).aspx”>TRY .. CATCH</a> block, so you can return whatever you want to the calling application when the duplicate key error is raised by the database.

——————–

Discuss This Question: 2  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • MelanieYarbrough
    Sukas, In order to avoid confusion, I've moved the information from the additional question you created related to this one. Sukas: "Thanks for that I did created the stored procedure I am using VB not C# kindly have look behind the code. Partial Class Page2DataSet1 Partial Class Page2DataTable Private Sub Page2DataTable_ColumnChanging(ByVal sender As System.Object, ByVal e As System.Data.DataColumnChangeEventArgs) Handles Me.ColumnChanging If (e.Column.ColumnName = Me.IDColumn.ColumnName) Then 'Add user code here End If End Sub End Class End Class" Thanks, Melanie
    6,345 pointsBadges:
    report
  • carlosdl
    Thanks Melanie. Sukas, please be more specific about your problem. The above code doesn't seem to be related to the INSERT operation you originally mentioned, so please provide more details. Thanks,
    68,330 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following