multiple table in datagrid

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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
 
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
 
Back
Top