By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,247 Members | 1,057 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,247 IT Pros & Developers. It's quick & easy.

Data Relation

P: n/a
Hi Guys,

I am trying to display a datagrid containing two related datasets. I have
filled and related them on MemberID with the following code:-

Dim myconnection As Odbc.OdbcConnection

Dim myda As Odbc.OdbcDataAdapter

Dim mysql As String

myconnection = New Odbc.OdbcConnection("DSN=database")

'get data from members table

mysql = "Select * from tblMembers"

myda = New Odbc.OdbcDataAdapter(mysql, myconnection)

myda.Fill(ds, "Members")

'get data from Category table

mysql = "Select * from tblMemberCategory"

myda = New Odbc.OdbcDataAdapter(mysql, myconnection)

myda.Fill(ds, "Category")

'added the data relation

ds.Relations.Add("AllMembers", ds.Tables("Members").Columns("MemberID"),
ds.Tables("Category").Columns("MemberID"))

'Set the datagrid source and populate the Datagrid

DataGridMember.DataSource = ds.Tables("AllMembers")

DataGridMember.TableStyles.Clear()

DataGridMember.Visible = True

'Close the Data connection when complete

myconnection.Close()

All I end up with is an empty datagrid. Any ideas why?

Cheers

Peter.

Nov 21 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Peter,

I am trying to display a datagrid containing two related datasets. I have
filled and related them on MemberID with the following code:-


You can not use a relation between two datasets, therefore is exactly the
dataset. It can holds relations between tables *in* a dataset.

I hope this helps,

Cor
Nov 21 '05 #2

P: n/a
Cor,

Isn't that what I have? I have one Dataset call ds with two tables, Members
and Category. Shouldn't Data Relation hold the relation between those two
tables in the same dataset?

Cheers

Peter.
"Cor Ligthert" <no************@planet.nl> wrote in message
news:ut**************@TK2MSFTNGP14.phx.gbl...
Peter,

I am trying to display a datagrid containing two related datasets. I have
filled and related them on MemberID with the following code:-


You can not use a relation between two datasets, therefore is exactly the
dataset. It can holds relations between tables *in* a dataset.

I hope this helps,

Cor

Nov 21 '05 #3

P: n/a
Peter,

I am trying to display a datagrid containing two related datasets. I
have filled and related them on MemberID with the following code:-
You can not use a relation between two datasets, therefore is exactly the
dataset. It can holds relations between tables *in* a dataset.
Isn't that what I have? I have one Dataset call ds with two tables,
Members and Category. Shouldn't Data Relation hold the relation between
those two tables in the same dataset?

When I see in a text something that can be the error, than I answer that. I
think than non of us start examining if there are more errors. Therefore
please give good information.

In the way you ask your question it is in my opinion not so clever to get
help. Maybe there are more misleading things that we should suppose to know.

By instance a special reason that you clear the grid style and set the
dataset to the table, or that you see a + as first row of your grid, however
no data. etc etc.

Cor
Nov 21 '05 #4

P: n/a
Cor,

Thanks for the reply.

I have tried a number of ways to display the data but am not successful.

if I change

DataGridMember.DataSource = ds.Tables("AllMembers")

to

DataGridMember.DataSource = ds.Tables("Members")

I can see the datagrid with the + sign in the first row. But I would like to
display the related fields in the same datagrid (with the additional
columns). Maybe this is not possible.

Thanks for your help.

Peter.


"Cor Ligthert" <no************@planet.nl> wrote in message
news:ui*************@TK2MSFTNGP12.phx.gbl...
Peter,

I am trying to display a datagrid containing two related datasets. I
have filled and related them on MemberID with the following code:- You can not use a relation between two datasets, therefore is exactly
the dataset. It can holds relations between tables *in* a dataset.

Isn't that what I have? I have one Dataset call ds with two tables,
Members and Category. Shouldn't Data Relation hold the relation between
those two tables in the same dataset?

When I see in a text something that can be the error, than I answer that.
I think than non of us start examining if there are more errors. Therefore
please give good information.

In the way you ask your question it is in my opinion not so clever to get
help. Maybe there are more misleading things that we should suppose to
know.

By instance a special reason that you clear the grid style and set the
dataset to the table, or that you see a + as first row of your grid,
however no data. etc etc.

Cor

Nov 21 '05 #5

P: n/a
Peter

Did you try this one already?

\\\
DataGridMember.DataSource = ds
DataGrid1.Expand(-1)
///

Cor
Nov 21 '05 #6

P: n/a
Cor,

I'll give it a go. I eventually linked the two tables together in an Access
query and displayed that. Not the most elegant way but it worked.

Thanks for your help.

Peter.
"Cor Ligthert" <no************@planet.nl> wrote in message
news:u0**************@TK2MSFTNGP09.phx.gbl...
Peter

Did you try this one already?

\\\
DataGridMember.DataSource = ds
DataGrid1.Expand(-1)
///

Cor

Nov 21 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.