473,396 Members | 2,121 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Data Relation

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
6 1844
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
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
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
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
Peter

Did you try this one already?

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

Cor
Nov 21 '05 #6
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jordan O'Hare | last post by:
Hello Everyone, I am after some help with the following: I have a windows application that contains a list box and two data grids. All three controls are binded to a dataset that contains...
1
by: Iain | last post by:
I've a fairly complex schema which I'm trying to create a typed data set for. I've had a number of issues to date but it is sort of working (e.g. elements are not considered nullable unless...
11
by: deko | last post by:
If I release a new version of my mbd (in mde format) and users want to upgrade - how do they migrate their data? For example, if the original was released as data1.mde and then I release...
5
by: Mikael Syska | last post by:
Hi, I have 2 talbes in a DataSet, and made a DataRelation between the 2 tables in the DataSet. One of the Tables are displayed in a datagrid, and when one of them is selected in the datagrid...
0
by: Joe Van Meer | last post by:
Hi all, I have a question regarding data relations within a data set. Say I have 3 tables named CLIENT, BOOKING and EMPLOYEE and I wanted to relate the first two tables (CLIENT AND BOOKING)...
11
by: Thomas A | last post by:
Hi, I fill a datgrid with data from a xml document, it works fine But.... Now I will to filter the data to the grid so only the data shows from the criteria that I set. My code now is very...
8
by: Jon Vaughan | last post by:
I have a hierachical dataset brought back from a sql server stored procedure with a design as follows : StaffID <Staff Columns> AddressID <Address Columns> StaffID_FK
5
by: sutphinwb | last post by:
Hi - This could be a simple question. When I relate two tables in a datasetet, how do I get that relation to show up in a GridView? The only way I've done it, is to create a separate table in the...
1
by: Ginger Estherskip | last post by:
I'm setting up a dataset using the GUI to have a Parent Data Table and a few Child Data Tables. I then have a form that uses that dataset, and I can fill the appropriate datatables et. al., but...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.