468,491 Members | 1,950 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,491 developers. It's quick & easy.

Tables with relations in a Dataset?

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
Nov 20 '05 #1
6 6364
Hi Lars,

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

http://support.microsoft.com/default...b;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
///
Nov 20 '05 #2
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


"Cor Ligthert" <no**********@planet.nl> skrev i meddelandet
news:eW**************@TK2MSFTNGP11.phx.gbl...
Hi Lars,

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

http://support.microsoft.com/default...b;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
///

Nov 20 '05 #3
Hi Lars,

I said it was a sample I had, in the XML file you can see the relations,

However do you have the resource kit.

With this and the samples for a Master-detail grid you should find
everything in my opinion.
(There are more samples for a Master detail grid in the resource kit)

http://msdn.microsoft.com/vbasic/vbrkit/default.aspx

And if you have problems installing it

http://msdn.microsoft.com/vbasic/vbr...q/#installvdir

I hope this helps a little bit?

Cor
Nov 20 '05 #4
Hi,

http://www.onteorasoftware.com/downloads/multigrids.zip

Ken
-------------------
"Lars Netzel" <la*********@qlogic.se> wrote in message
news:Oq**************@TK2MSFTNGP09.phx.gbl...
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

Nov 20 '05 #5
Thank you!

/Lars

"Cor Ligthert" <no**********@planet.nl> skrev i meddelandet
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hi Lars,

I said it was a sample I had, in the XML file you can see the relations,

However do you have the resource kit.

With this and the samples for a Master-detail grid you should find
everything in my opinion.
(There are more samples for a Master detail grid in the resource kit)

http://msdn.microsoft.com/vbasic/vbrkit/default.aspx

And if you have problems installing it

http://msdn.microsoft.com/vbasic/vbr...q/#installvdir

I hope this helps a little bit?

Cor

Nov 20 '05 #6
Thank you!

/Lars

"Cor Ligthert" <no**********@planet.nl> skrev i meddelandet
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hi Lars,

I said it was a sample I had, in the XML file you can see the relations,

However do you have the resource kit.

With this and the samples for a Master-detail grid you should find
everything in my opinion.
(There are more samples for a Master detail grid in the resource kit)

http://msdn.microsoft.com/vbasic/vbrkit/default.aspx

And if you have problems installing it

http://msdn.microsoft.com/vbasic/vbr...q/#installvdir

I hope this helps a little bit?

Cor

Nov 20 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Steve Klett | last post: by
4 posts views Thread by Joe Van Meer | last post: by
2 posts views Thread by Bennett Haselton | last post: by
8 posts views Thread by Jason L James | last post: by
3 posts views Thread by Bob | last post: by
6 posts views Thread by Laura K | last post: by
2 posts views Thread by Henrik | last post: by
reply views Thread by NPC403 | last post: by
3 posts views Thread by gieforce | last post: by
reply views Thread by theflame83 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.