473,770 Members | 1,523 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 #1
14 1713
davef
98 New Member
The code looks alright to me. What's the error you're getting again?
Sep 27 '07 #2
kjewell23
49 New Member
thats the thing I'm not getting no error I'm not getting 3 columns that I need from the table
The code looks alright to me. What's the error you're getting again?
Sep 27 '07 #3
davef
98 New Member
thats the thing I'm not getting no error I'm not getting 3 columns that I need from the table
Which columns are missing from the dataset?
Sep 27 '07 #4
kjewell23
49 New Member
There are the ptyp1, ptyp2, and the descp fields that are missing.
Which columns are missing from the dataset?
Sep 27 '07 #5
davef
98 New Member
There are the ptyp1, ptyp2, and the descp fields that are missing.
Is your gridview supposed to have hierarchical Master-Detail structure?
Sep 27 '07 #6
kjewell23
49 New Member
I don't know. Does it
Is your gridview supposed to have hierarchical Master-Detail structure?
Sep 27 '07 #7
davef
98 New Member
I don't know. Does it
I could post the code that builds a Master-Detail DataGrid if that would help your problem.
Sep 27 '07 #8
kjewell23
49 New Member
I could post the code that builds a Master-Detail DataGrid if that would help your problem.

sure it wouldn't hurt to try it. I have a gridview not a datagrid
Sep 27 '07 #9
davef
98 New Member
sure it wouldn't hurt to try it. I have a gridview not a datagrid
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 #10

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
9425
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
10231
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...
1
10005
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
9871
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
8887
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...
1
7416
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
5313
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
5452
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3972
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

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.