multiple table in datagrid

G

Guest

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
 
G

Guest

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
 
G

Guest

I sorted out the problem. Thanks ken

Thanks said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top