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
14 1713
The code looks alright to me. What's the error you're getting again?
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?
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?
There are the ptyp1, ptyp2, and the descp fields that are missing.
Which columns are missing from the dataset?
There are the ptyp1, ptyp2, and the descp fields that are missing.
Is your gridview supposed to have hierarchical Master-Detail structure?
I don't know. Does it
Is your gridview supposed to have hierarchical Master-Detail structure?
I don't know. Does it
I could post the code that builds a Master-Detail DataGrid if that would help your problem.
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
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: -
private void Form1_Load( object sender, EventArgs e )
-
{
-
string szConn = "Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Northwind;Data Source=server-name";
-
string szSQL = "select * from dbo.Categories";
-
SqlConnection conn = new SqlConnection( szConn );
-
SqlCommand command = new SqlCommand( szSQL );
-
-
if( conn.State != ConnectionState.Open )
-
conn.Open();
-
-
command.Connection = conn;
-
SqlDataAdapter adapter = new SqlDataAdapter( command );
-
DataSet ds = new DataSet();
-
adapter.Fill( ds, "Categories" );
-
-
szSQL = "select * from Products";
-
command.CommandText = szSQL;
-
adapter.Fill( ds, "Products" );
-
-
DataRelation relation = new DataRelation(
-
"CategoryProduct", ds.Tables["Categories"].Columns["CategoryID"],
-
ds.Tables["Products"].Columns["CategoryID"], true );
-
ds.Relations.Add( relation );
-
-
-
this.dataGrid1.DataSource = ds;
-
this.dataGrid1.DataMember = "Categories";
-
conn.Close();
-
}
-
Sign in to post your reply or Sign up for a free account.
Similar topics |
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?
|
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...
|
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
...
|
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
|
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
| |
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"
|
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
|
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
|
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)
|
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,...
|
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...
| |
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,...
|
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...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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
| |