I'm new to C#, and i need help with the following problem:
I have a DataTable called 'Nomes', part of a DataSet with various datatables.
I am searching a record (that i know it exists) in that DataTable. I need two fields from that DataTable to compose the key.
Example: i'm looking for the record where field 'Codigo' = '000100' and field 'CPostal' = '3000-001'.
Expand|Select|Wrap|Line Numbers
- // Defining fields 'codigo' + 'cpostal' as key fields
- Nomes.PrimaryKey = new DataColumn[] {Nomes.Columns["codigo"], Nomes.Columns["cpostal"]} ;
- // Defining values to locate
- object Chave = new object[] { "000100", "3000-001" };
- // Using object 'Chave' search the record where codigo = "000100" and cpostal = "3000-001"
- DataRow RegistoEncontrado = Nomes.Rows.Find(Chave);
"Expecting 2 value(s) for the key being indexed, but received 1 value(s)."
I think this error message don't make much sense, because the parameter send to the find() method was an object with 2 values.
Does anybody knows what have i done wrong?
TIA,
Joaquim