marlin Posted October 28, 2004 Posted October 28, 2004 I need to search for a value in the primary key column in a datatable to see if there is a match. If there is a match, I will display a message that this is a duplicate value. How do I search a value in the primary key column, or are there different ways of accomplishing this? Any help is appreciated. Quote
Administrators PlausiblyDamp Posted October 28, 2004 Administrators Posted October 28, 2004 Would a normal select of the form SELECT FROM WHERE = not do the trick? Or do you want to actually list the duplicates? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
marlin Posted October 28, 2004 Author Posted October 28, 2004 Would a normal select of the form SELECT <PK Column Name> FROM <Table Name> WHERE <PK Column Name> = <value to search for> not do the trick? Or do you want to actually list the duplicates? Thank you for your response. I am working with the Datatable object which is part of a Dataset object. The Datatable object is created in the code. I programmatically add new data to the Datatable object. What I try to do is to verify that the new data to be added to the Datatable does not already exist in the Datatable. If you have any suggestion, I'll appreciate it. Thanks. Quote
wayneph Posted October 28, 2004 Posted October 28, 2004 Will this work? Dim r as DataRow = myTable.Rows.Find(ValueToFind) If r Is Nothing Then 'The Value was NOT found Else 'The value was found End If Quote wayne The Road Goes on Forever and the Party Never Ends - Robert Earl Keen
marlin Posted October 28, 2004 Author Posted October 28, 2004 Will this work? Dim r as DataRow = myTable.Rows.Find(ValueToFind) If r Is Nothing Then 'The Value was NOT found Else 'The value was found End If That works out great!! Thank you so much wayneph. I appreciate it. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.