10 pts.
 Avoid duplicate entry in database through 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.
ASKED: September 17, 2010  10:29 PM
UPDATED: September 20, 2010  3:01 PM

Answer Wiki:
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. --------------------
Last Wiki Answer Submitted:  September 17, 2010  11:07 pm  by  carlosdl   63,535 pts.
All Answer Wiki Contributors:  carlosdl   63,535 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


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


 

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,315 pts.

 

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,

 63,535 pts.