473,657 Members | 2,450 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.OdbcConnec tion

Dim myda As Odbc.OdbcDataAd apter

Dim mysql As String

myconnection = New Odbc.OdbcConnec tion("DSN=datab ase")

'get data from members table

mysql = "Select * from tblMembers"

myda = New Odbc.OdbcDataAd apter(mysql, myconnection)

myda.Fill(ds, "Members")

'get data from Category table

mysql = "Select * from tblMemberCatego ry"

myda = New Odbc.OdbcDataAd apter(mysql, myconnection)

myda.Fill(ds, "Category")

'added the data relation

ds.Relations.Ad d("AllMembers ", ds.Tables("Memb ers").Columns(" MemberID"),
ds.Tables("Cate gory").Columns( "MemberID") )

'Set the datagrid source and populate the Datagrid

DataGridMember. DataSource = ds.Tables("AllM embers")

DataGridMember. TableStyles.Cle ar()

DataGridMember. Visible = True

'Close the Data connection when complete

myconnection.Cl ose()

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

Cheers

Peter.

Nov 21 '05 #1
6 1855
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******** ******@TK2MSFTN GP14.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("AllM embers")

to

DataGridMember. DataSource = ds.Tables("Memb ers")

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******** *****@TK2MSFTNG P12.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.Expan d(-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******** ******@TK2MSFTN GP09.phx.gbl...
Peter

Did you try this one already?

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

Cor

Nov 21 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
4867
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 five tables, and three relations that I want to take advantage of. Everything works fine however I want to use the data grid table style editor to make it look more presentable. Currently I have successfully done this
1
1568
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 minOccurs="0" is present. If not the codegen:nullValue attribute is ignored). What I'm seeing at the moment is that if I do NOT add in key and key ref relations, the cs generated puts in sensibly named relations with appropriate accessors. But...
11
2404
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 data2.mde (same table/data structures - just revised VBA code with perhaps a new/updated form or two), what's the best way for users to get their data into the new data2.mde? I'm thinking I could use a query - something like:
5
2345
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 I want its childcolumns to be displayed in a second datagrid. How can I filter the dataset or get only the related data into the
0
1182
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) via a clientid and relate the second set of tables (BOOKING AND EMPLOYEE) using an employeeid. My problem arises when there a re no records in one of the tables in either data relation. What is the best way to handle this, check the number of...
11
2132
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 simple to fill the grid
8
1097
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
6436
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 dataset with a join query for the GetData() select method. I use ObjectDataStore to couple the GridView with the table adapter on the dataset. If I point the ODS at the child table, the GridView will bind to the "normal" select and I end up...
1
1467
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 I can't figure out how that parent/child relationship gets enforced? It's a one to one relationship, and when I bind a textedit to the child table row, it's not the row that matches the relation with the parent table. Pretend it's a Shirt
0
8421
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8844
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8742
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8518
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8621
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7354
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1971
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.