Tables with relations in a Dataset?

  • Thread starter Thread starter Lars Netzel
  • Start date Start date
L

Lars Netzel

I have a VB.NET application based on MS access 2000 db.

I have a 1 to many relation between 4 tables...

tbl1 -> tbl2 -> tbl3 -> tbl4 (all with "one to many" relations)

I need to create a Dataset that includes all these tables and keeps the
realtion

When I use an OLEdb Adapter and generate a dataset (in VS) based on that I
get all the tables' columns in one long dataset and the relations are all
gone.

How do I solve this?

/Lars
 
Hi Lars,

I do not know if you use the join, however there is a bug in that.

http://support.microsoft.com/default.aspx?scid=kb;en-us;318646

I made a sample with relations for Access.

I hope that will help you a little bit?.


Cor
\\\\
Dim Sql As String = "SELECT * from A, B Where " & _
"A.n = B.n AND A.n = 10"
Dim Conn As New OleDbConnection(connString)
Dim da As New OleDbDataAdapter(Sql, Conn)
da.Fill(ds, "A")
da.Fill(ds, "B")
Conn.Close()
Dim drlA As New DataRelation _
("AA", ds.Tables("A").Columns("A.n"), _
ds.Tables("B").Columns("B.n"))
ds.Relations.Add(drlA)
Dim dv As New DataView(ds.Tables("A"))
DataGrid1.DataSource = dv
DataGrid1.Expand(-1)
ds.WriteXml("mypath", XmlWriteMode.WriteSchema)
End Sub
///
 
Can I use the XML file for something after doing this or why do you write
one in the example? Can I rename that one to a *.xsd extention and include
in the project and use somehow?

Also, the relation that shows up in the datagrid... I want to have each
table in the dataset in it's own datagrid.. is that possible?

/Lars
 
Back
Top