Concatentated Primary Key Searching with .NET

Nov 25, 2011 Author thepauleh@gmail.com

So here’s a little gem. Now, I’m in the CODD’s school of thought that composite keys are evil – but sometimes to quickly fit an existing system it is necessary. Just makes me shudder as I look at that one table I couldn’t normalise.

dim objFindValues(numOfKeys-1) as object ‘create an array with the elements
to match the number of columns in the primary key

objFindValues(0) = value1
objFindValues(1) = value

‘ Then we use the array as the search argument.
dataRow = dataSet.Tables(“TableName”).Rows.Find(objFindValues)