B
Billy
I need some help with solving my problem.
I'm writing general procedure to find a values in any table. My idea is
to pass to that procedure: TableName and ArrayList with parametere.
Arraylist contain FieldName and Value for that FieldName. Every table
has Primary key which can have one or more fields in that PK.
My problems is that I don't know how to pass that parameters in
arbitrary way. For e.g. in below example from help you have to pass
parameters in EXACT same order as fields in PK is written. So how to
write below example that each passed value will be bound to specific
field in PK not with index but by name of the field in PK??
Private Sub FindInMultiPKey(ByVal myTable As DataTable)
Dim foundRow As DataRow
' Create an array for the key values to find.
Dim findTheseVals(2) As Object
' Set the values of the keys to find.
findTheseVals(0) = "John"
findTheseVals(1) = "Smith"
findTheseVals(2) = "5 Main St."
foundRow = myTable.Rows.Find(findTheseVals)
' Display column 1 of the found row.
If Not (foundRow Is Nothing) Then
Console.WriteLine(foundRow(1).ToString())
End If
End Sub
I'm writing general procedure to find a values in any table. My idea is
to pass to that procedure: TableName and ArrayList with parametere.
Arraylist contain FieldName and Value for that FieldName. Every table
has Primary key which can have one or more fields in that PK.
My problems is that I don't know how to pass that parameters in
arbitrary way. For e.g. in below example from help you have to pass
parameters in EXACT same order as fields in PK is written. So how to
write below example that each passed value will be bound to specific
field in PK not with index but by name of the field in PK??
Private Sub FindInMultiPKey(ByVal myTable As DataTable)
Dim foundRow As DataRow
' Create an array for the key values to find.
Dim findTheseVals(2) As Object
' Set the values of the keys to find.
findTheseVals(0) = "John"
findTheseVals(1) = "Smith"
findTheseVals(2) = "5 Main St."
foundRow = myTable.Rows.Find(findTheseVals)
' Display column 1 of the found row.
If Not (foundRow Is Nothing) Then
Console.WriteLine(foundRow(1).ToString())
End If
End Sub