¿Cómo navegar desde tablas de conjuntos de datos usando relaciones y enlaces?

I have an application with VB.Net and I am using a dataset with two data tables. i made relation between the two tables and navigate through data. I navigate from one one record to on other. But i want also to use the relation between the tables in the dataset and also get the records from the other table. is there any way to do this? the following code shows how i display data:

sql = "select * from COMPUTER"
da = New SqlDataAdapter(sql, sqlConn)
da.Fill(dsPC, "pcTable")

sql = "select * from COMPUTER_BRAND"
da = New SqlDataAdapter(sql, sqlConn)
da.Fill(dsPC, "pcBrand") 

pcLocation = New DataRelation("pcLocation", 
                              dsPC.Tables("pcTable").Columns(0),
                              dsPC.Tables("pcLocation").Columns(1))   
dsPC.Relations.Add(pcLocation)

now, how to navigate between the records in the data tables?

preguntado el 31 de julio de 12 a las 10:07

1 Respuestas

Tienes que usar el Obtener filas secundarias método.


Ejemplo:

For Each row in dsPC.Tables("pcTable").Rows
    Dim child_rows = row.GetChildRows(pcLocation)     
    ' Do something with child rows    
Next

Respondido el 01 de junio de 15 a las 22:06

How to do it in reverse? - Faizán Mubasher

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.