473,785 Members | 2,842 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ds. relations problem with dataset

49 New Member
Hi. I have the code working just fine except all the data isn't coming up with the ds.relations code. Could you see what I'm doing wrong or what else I need to add. Code down below
Dim adapter As OdbcDataAdapter = New OdbcDataAdapter (command)
Dim ds As DataSet = New DataSet()
adapter.SelectC ommand = New OdbcCommand("se lect rmsfiles2.obcop 200.line#, rmsfiles2.obcop 200.ordno, rmsfiles2.obcop 200.quano, rmsfiles2.obcop 200.quana, rmsfiles2.obcop 200.quans, rmsfiles2.obcop 200.c2rdt, rmsfiles2.obcop 200.unitm, rmsfiles2.obcop 200.actsp, rmsfiles2.obcop 200.prdno from rmsfiles2.obcop 200 where ordno = " & Order.ToString( ), myConnection)
adapter.Fill(ds , "OBCOP200")

adapter.SelectC ommand = New OdbcCommand("se lect rmsfiles2.mspmp 100.ptyp1, rmsfiles2.mspmp 100.ptyp2, rmsfiles2.mspmp 100.descp, rmsfiles2.mspmp 100.prdno from rmsfiles2.obcop 200 inner join rmsfiles2.mspmp 100 on rmsfiles2.obcop 200.prdno = rmsfiles2.mspmp 100.prdno where rmsfiles2.obcop 200.ordno = " & Order.ToString( ), myConnection)
adapter.Fill(ds , "MSPMP100")

ds.Tables(0).Ta bleName = "OBCOP200"
ds.Tables(1).Ta bleName = "MSPMP100"
Dim relation As New DataRelation("O BCOP200MSPMP100 ", ds.Tables("OBCO P200").Columns( "prdno"), ds.Tables("MSPM P100").Columns( "prdno"), False)
' ds.Relations.Ad d("OBCOP200MSPM P100", ds.Tables("OBCO P200").Columns( "prdno"), ds.Tables("MSPM P100").Columns( "prdno"), True)
ds.Relations.Ad d(relation)

gridview1.DataS ource = ds
gridview1.DataB ind()
If ds.Tables(0).Ro ws.Count = 0 Then
lbl_error.Visib le = True
gridview1.Visib le = False
Else
lbl_error.Visib le = False
gridview1.Visib le = True
End If

If ds.Tables(1).Ro ws.Count = 0 Then
lbl_error.Visib le = True
gridview1.Visib le = False
Else
lbl_error.Visib le = False
gridview1.Visib le = True
End If
Sep 27 '07
14 1714
kjewell23
49 New Member
I don't have that installed on my machine so It don't help me. Its all the same code except the sql commands and of course the tables

You must have Nortwind SQL Server db installed for this sample to run. Place a DataGrid (not DataGridView) object on the form. Here's you Form_Load event handler implementation:
Expand|Select|Wrap|Line Numbers
  1.         private void Form1_Load( object sender, EventArgs e )
  2.         {
  3.             string szConn = "Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Northwind;Data Source=server-name";
  4.             string szSQL = "select * from dbo.Categories";
  5.             SqlConnection conn = new SqlConnection( szConn );
  6.             SqlCommand command = new SqlCommand( szSQL );
  7.  
  8.             if( conn.State != ConnectionState.Open )
  9.                 conn.Open();
  10.  
  11.             command.Connection = conn;
  12.             SqlDataAdapter adapter = new SqlDataAdapter( command );
  13.             DataSet ds = new DataSet();
  14.             adapter.Fill( ds, "Categories" );
  15.  
  16.             szSQL = "select * from Products";
  17.             command.CommandText = szSQL;
  18.             adapter.Fill( ds, "Products" );
  19.  
  20.             DataRelation relation = new DataRelation(
  21.                 "CategoryProduct", ds.Tables["Categories"].Columns["CategoryID"],
  22.                 ds.Tables["Products"].Columns["CategoryID"], true );
  23.             ds.Relations.Add( relation );
  24.  
  25.  
  26.             this.dataGrid1.DataSource = ds;
  27.             this.dataGrid1.DataMember = "Categories";
  28.             conn.Close();
  29.         }
  30.  
Sep 27 '07 #11
davef
98 New Member
I don't have that installed on my machine so It don't help me. Its all the same code except the sql commands and of course the tables
A DataGridView is not hierarchical by design so you can present the contents of only one table of the dataset at a time. Try to set the DataMember property to the specific table and massage the data beforehand.
Sep 27 '07 #12
kjewell23
49 New Member
A DataGridView is not hierarchical by design so you can present the contents of only one table of the dataset at a time. Try to set the DataMember property to the specific table and massage the data beforehand.
well i added the datamember to the first table between the datasource and databind. the massage part i dont' know what you are talking about
Sep 27 '07 #13
davef
98 New Member
well i added the datamember to the first table between the datasource and databind. the massage part i dont' know what you are talking about
Does your first datatable contain the fields you're missing from the grid now?
Sep 27 '07 #14
kjewell23
49 New Member
the fields that im missing is in the second table i tried both tables for the datamember and still missing
Does your first datatable contain the fields you're missing from the grid now?
Sep 27 '07 #15

Sign in to post your reply or Sign up for a free account.

Similar topics

1
1210
by: womber | last post by:
What do you think is the best design approach when your trying to get nested XML results from dataSet.GetXML. Define the relations in the dataset or apply an XSLT stylesheet to nest the results by syncing the dataset with an XMLdocument?
0
1187
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...
1
1439
by: Ravi | last post by:
I am trying to represent master-detail records from a database The general logic will be populating the first dropdownlist with the master records and on change of the first dropdownlis getting the selectedindex and querying the database and populating the childrecords in the second dropdownlist But my question is how the same can be acheieved by using "Relations" The following code fragment i tried, but i have no idea how to proceed ...
4
3890
by: What-a-Tool | last post by:
I am trying to write a program that will take all the members of a data base, add them to a tree, with all child relations as sub-nodes. I am having a problem getting the parent child relations for each table & query. Dim tblCurrent As DataTable Dim strTableName As string For Each tblCurrent In Ds1.Tables
6
1102
by: Geoff Jones | last post by:
Hi I have two tables to which I have created a one-to-many relationship. How do I sort the result of the relationship? For example, if one column contains dates, how do I display in the dates in order in a DataGrid? Thanks in advance Geoff
1
5132
by: Randy Fraser | last post by:
How do I create a relationship on muliple columns in an untyped dataset. Why does this not work. da.Fill(ds) ds.Tables(0).TableName = "DesignSummary" ds.Tables(1).TableName = "FormulaSummary" ds.Tables(2).TableName = "MaterialSummary" ds.Tables(3).TableName = "ItemUsage" ds.Tables(5).TableName = "UsageSummary"
2
2871
by: Joe | last post by:
Hi I have a dataset with 3 tables and 2 relations Is there a way to when I am at 1 row to tell if there is a relation on that row ??? I have the code hardcoded but try to make it work if the # of tables and #relations increase or decrease So I can just pass any dataset and walk thru the rows?? Thanks
2
2494
by: Joe | last post by:
Hi I am going to receive a dataset downstream and I will not know the the fields number of field relations number of relations So I have to be flexible to take unknown data and be able to summarize all the info being passed
9
4026
by: Anil Gupte | last post by:
After reading a tutorial and fiddling, I finally got this to work. I can now put two tables created with a DataTable class into a DataRelation. Phew! And it works! Dim tblSliceInfo As New DataTable("SliceInfo") Dim tblSliceRatings As New DataTable("SliceRatings") '.... All the adding datacolumns, datarows, etc. goes here.. DatasetInit.Tables.Add(tblSliceInfo)
0
9645
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
9480
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10330
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
10153
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
7500
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6740
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4053
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3654
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.