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.SelectCommand = New OdbcCommand("select rmsfiles2.obcop200.line#, rmsfiles2.obcop200.ordno, rmsfiles2.obcop200.quano, rmsfiles2.obcop200.quana, rmsfiles2.obcop200.quans, rmsfiles2.obcop200.c2rdt, rmsfiles2.obcop200.unitm, rmsfiles2.obcop200.actsp, rmsfiles2.obcop200.prdno from rmsfiles2.obcop200 where ordno = " & Order.ToString(), myConnection)
adapter.Fill(ds, "OBCOP200")
adapter.SelectCommand = New OdbcCommand("select rmsfiles2.mspmp100.ptyp1, rmsfiles2.mspmp100.ptyp2, rmsfiles2.mspmp100.descp, rmsfiles2.mspmp100.prdno from rmsfiles2.obcop200 inner join rmsfiles2.mspmp100 on rmsfiles2.obcop200.prdno = rmsfiles2.mspmp100.prdno where rmsfiles2.obcop200.ordno = " & Order.ToString(), myConnection)
adapter.Fill(ds, "MSPMP100")
ds.Tables(0).TableName = "OBCOP200"
ds.Tables(1).TableName = "MSPMP100"
Dim relation As New DataRelation("OBCOP200MSPMP100", ds.Tables("OBCOP200").Columns("prdno"), ds.Tables("MSPMP100").Columns("prdno"), False)
' ds.Relations.Add("OBCOP200MSPMP100", ds.Tables("OBCOP200").Columns("prdno"), ds.Tables("MSPMP100").Columns("prdno"), True)
ds.Relations.Add(relation)
gridview1.DataSource = ds
gridview1.DataBind()
If ds.Tables(0).Rows.Count = 0 Then
lbl_error.Visible = True
gridview1.Visible = False
Else
lbl_error.Visible = False
gridview1.Visible = True
End If
If ds.Tables(1).Rows.Count = 0 Then
lbl_error.Visible = True
gridview1.Visible = False
Else
lbl_error.Visible = False
gridview1.Visible = True
End If
14 1668
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();
-
}
-
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: -
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();
-
}
-
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.
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
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?
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?
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...
|
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)...
|
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...
|
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...
|
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...
|
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"...
|
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 #...
|
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...
|
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...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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,...
|
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...
|
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...
|
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,...
| |