I meet a system.ArgumentException: cannot create a child list for field x.
my coding as follow
Dim cn As SqlConnection
Dim da As SqlDataAdapter, da1 As SqlDataAdapter
Dim ds As DataSet
Try
cn = New SqlConnection(str)
cn.Open()
da1 = New SqlDataAdapter("select id,Name from x", cn)
da = New SqlDataAdapter("select id,Code from y", cn)
ds = New DataSet
da1.Fill(ds, "x")
da.Fill(ds, "y")
ds.Relations.Add("z", _
ds.Tables("x").Columns("id"), _
ds.Tables("y").Columns("id"))
Me.mygrid.DataSource = ds.Tables("x")
Me.mygrid.DataMember = "x.z"
Catch e As Exception
MessageBox.Show(e.ToString)
Finally
cn.Close()
End Try
What's wrong of my coding? I would like to remove the error message ...
Thanks 3 1094
Hi,
When you bind to a datareleation you need to use setbinding. Here
is an example. http://www.windowsformsdatagridhelp....7-7bc3068aca2c
Ken
-------------------------
"Thanks" <Th****@discussions.microsoft.com> wrote in message
news:C6**********************************@microsof t.com... I meet a system.ArgumentException: cannot create a child list for field x.
my coding as follow
Dim cn As SqlConnection Dim da As SqlDataAdapter, da1 As SqlDataAdapter Dim ds As DataSet
Try
cn = New SqlConnection(str) cn.Open()
da1 = New SqlDataAdapter("select id,Name from x", cn)
da = New SqlDataAdapter("select id,Code from y", cn)
ds = New DataSet
da1.Fill(ds, "x") da.Fill(ds, "y")
ds.Relations.Add("z", _ ds.Tables("x").Columns("id"), _ ds.Tables("y").Columns("id"))
Me.mygrid.DataSource = ds.Tables("x") Me.mygrid.DataMember = "x.z"
Catch e As Exception MessageBox.Show(e.ToString) Finally cn.Close() End Try
What's wrong of my coding? I would like to remove the error message ...
Thanks
Hi ken
Thanks for your web site. After adding the setdatabinding, the
system.ArgumentException still exist ... no luck!
Me.mygrid.SetDataBinding(ds, "x")
Me.mygrid.SetDataBinding(ds, "y")
Me.mygrid.SetDataBinding(ds, "x.z")
Actually, after showing the system.ArgumentException, my datagrid can show
the data records that I want ... but I dont want the error message ...
any idea?
Thanks
"Ken Tucker [MVP]" wrote: Hi,
When you bind to a datareleation you need to use setbinding. Here is an example.
http://www.windowsformsdatagridhelp....7-7bc3068aca2c
Ken ------------------------- "Thanks" <Th****@discussions.microsoft.com> wrote in message news:C6**********************************@microsof t.com...I meet a system.ArgumentException: cannot create a child list for field x.
my coding as follow
Dim cn As SqlConnection Dim da As SqlDataAdapter, da1 As SqlDataAdapter Dim ds As DataSet
Try
cn = New SqlConnection(str) cn.Open()
da1 = New SqlDataAdapter("select id,Name from x", cn)
da = New SqlDataAdapter("select id,Code from y", cn)
ds = New DataSet
da1.Fill(ds, "x") da.Fill(ds, "y")
ds.Relations.Add("z", _ ds.Tables("x").Columns("id"), _ ds.Tables("y").Columns("id"))
Me.mygrid.DataSource = ds.Tables("x") Me.mygrid.DataMember = "x.z"
Catch e As Exception MessageBox.Show(e.ToString) Finally cn.Close() End Try
What's wrong of my coding? I would like to remove the error message ...
Thanks
I sorted out the problem. Thanks ken
"Thanks" wrote: Hi ken
Thanks for your web site. After adding the setdatabinding, the system.ArgumentException still exist ... no luck!
Me.mygrid.SetDataBinding(ds, "x") Me.mygrid.SetDataBinding(ds, "y") Me.mygrid.SetDataBinding(ds, "x.z")
Actually, after showing the system.ArgumentException, my datagrid can show the data records that I want ... but I dont want the error message ...
any idea? Thanks
"Ken Tucker [MVP]" wrote:
Hi,
When you bind to a datareleation you need to use setbinding. Here is an example.
http://www.windowsformsdatagridhelp....7-7bc3068aca2c
Ken ------------------------- "Thanks" <Th****@discussions.microsoft.com> wrote in message news:C6**********************************@microsof t.com...I meet a system.ArgumentException: cannot create a child list for field x.
my coding as follow
Dim cn As SqlConnection Dim da As SqlDataAdapter, da1 As SqlDataAdapter Dim ds As DataSet
Try
cn = New SqlConnection(str) cn.Open()
da1 = New SqlDataAdapter("select id,Name from x", cn)
da = New SqlDataAdapter("select id,Code from y", cn)
ds = New DataSet
da1.Fill(ds, "x") da.Fill(ds, "y")
ds.Relations.Add("z", _ ds.Tables("x").Columns("id"), _ ds.Tables("y").Columns("id"))
Me.mygrid.DataSource = ds.Tables("x") Me.mygrid.DataMember = "x.z"
Catch e As Exception MessageBox.Show(e.ToString) Finally cn.Close() End Try
What's wrong of my coding? I would like to remove the error message ...
Thanks This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Billy Jacobs |
last post by:
I am using a datagrid to display some data. I need to
create 2 header rows for this grid with columns of
varying spans. In html it would be the following.
<Table>
<tr>
<td colspan=8>Official...
|
by: berullus |
last post by:
I have a datagrid in windows form bound to a dataset which has list of tables
.. So, when the form is run I see + sign which could be expandable to range of
table names in the grid. How do I find...
|
by: Phil Townsend |
last post by:
I am building an online testing application that uses a usercontrol to
navigate through a list of questions. The questions are multiple choice.
I have a stored procedure that returns two tables:...
|
by: Andrew |
last post by:
Hey all,
I am very new to ASP.Net (and .Net in general), but that isn't stopping the
boss from wanting to begin new projects in it. This latest project has me
kinda stumped and after a couple...
|
by: Bob Loveshade |
last post by:
I am looking for an example that shows how to select and highlight
multiple rows in a DataGrid.
My DataGrid is part of a Web User Control which is contained in an ASPX
page.
I haven't been...
|
by: Dave Edwards |
last post by:
I understand that I can fill a datagrid with multiple queries, but I cannot
figure out how to fill a dataset with the same query but run against
multiple SQL servers, the query , table structure...
|
by: dbuchanan |
last post by:
How do I make multiple DataGridTableStyles serve the same table?
(I can get multiple styles for the same datagrid, but not multple
styles for the same *table* on the same datagrid)
I want to do...
|
by: Sam |
last post by:
Hi all
I have a database table that has multiple column primary key and every thing
looks fine when I load it in the datagrid web control. The problem is that
the datagrid web control can only...
|
by: rn5a |
last post by:
A DataGrid control displays records from a SQL Server 2005 DB table.
The AllowSorting property of the DataGrid has been set to True & the
SortExpressions of the BoundColumns have been set to the...
|
by: =?Utf-8?B?TG9zdEluTUQ=?= |
last post by:
Hi All :)
I'm converting VB6 using True DBGrid Pro 8.0 to VB2005 using DataGridView.
True DBGrid has a MultipleLines property that controls whether individual
records span multiple lines. Is...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
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: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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...
| |