Y
YBOTI
Perhaps I have the concept all wrong, but based on the documentation and
books I have read it seems this should work. I have multiple complex
datasets in an access db. They have 2 shared primary keys. I have another
dataset that shares one key with them. I need to end up with a single flat
dataset comprised of the merged sets. In a simpler world it would be a
normal sql join, but that is not an option.
Right now, I would love for someone to point out my stupidity and show me
the magic setting I have forgotten. An additional complication is that the
last dataset - the one with just one key was a "relation" issue because that
field in the other table was not unique values. It would be a many-to-one
relation.
I have tried using both the relation AND the merge to no avail. I am not
modifying this data. I just need to read it in, merge it based on the key
values, and kick it out as a single table. As a test I tried creating a more
simple 2 table set (in ms sql), read them into datasets, and tried to merge.
I just do not ever see a merged result. here is the code that goes with a
simple webform with one datagrid.
Dim ds1 As New DataSet()
Dim ds2 As New DataSet()
Dim da1 As New SqlDataAdapter()
Dim da2 As New SqlDataAdapter()
Dim cn As New SqlConnection()
cn.ConnectionString() = "server=daddy;database=test;uid=test;pwd=test"
cn.Open()
da1.SelectCommand = New SqlCommand("select * from table1", cn)
da1.Fill(ds1, "tbl1")
da2.SelectCommand = New SqlCommand("select * from table2", cn)
da2.Fill(ds1, "tbl2")
ds1.Merge(ds2, True, MissingSchemaAction.Add)
DataGrid1.DataSource = ds1
DataGrid1.DataBind()
books I have read it seems this should work. I have multiple complex
datasets in an access db. They have 2 shared primary keys. I have another
dataset that shares one key with them. I need to end up with a single flat
dataset comprised of the merged sets. In a simpler world it would be a
normal sql join, but that is not an option.
Right now, I would love for someone to point out my stupidity and show me
the magic setting I have forgotten. An additional complication is that the
last dataset - the one with just one key was a "relation" issue because that
field in the other table was not unique values. It would be a many-to-one
relation.
I have tried using both the relation AND the merge to no avail. I am not
modifying this data. I just need to read it in, merge it based on the key
values, and kick it out as a single table. As a test I tried creating a more
simple 2 table set (in ms sql), read them into datasets, and tried to merge.
I just do not ever see a merged result. here is the code that goes with a
simple webform with one datagrid.
Dim ds1 As New DataSet()
Dim ds2 As New DataSet()
Dim da1 As New SqlDataAdapter()
Dim da2 As New SqlDataAdapter()
Dim cn As New SqlConnection()
cn.ConnectionString() = "server=daddy;database=test;uid=test;pwd=test"
cn.Open()
da1.SelectCommand = New SqlCommand("select * from table1", cn)
da1.Fill(ds1, "tbl1")
da2.SelectCommand = New SqlCommand("select * from table2", cn)
da2.Fill(ds1, "tbl2")
ds1.Merge(ds2, True, MissingSchemaAction.Add)
DataGrid1.DataSource = ds1
DataGrid1.DataBind()