I need to merge two data schema into one. I have Schema1 and Schema2. I need to join these two into Schema3. Furthermore, I have a Select statement which queries a data set but I can’t figure out how to use the select statement on the data set containing both tables (both Schema1 and Schema2) and combine them into the new table schema3 which is a table in the same data set comprised of both table’s fields.
Example
Schema 1
ID,
Food,
Book,
Rice,
Cave
Schema 2
ID ,
Carpet,
Strings,
Run
Schema 3
ID,
Food,
Book,
Rice,
Cave,
Carpet,
Strings,
Run
Fill the Schema3 Table with this command
Sql Command:
Select * Schema1 [except ID] and all fields from Schema2 [exceptID] Inner Join
Schema2 ON Schema1.ID = Schema2.ID
Where ID = {dynamically defined variable 'X'}
Please excuse the lack of proper syntax. The main issue here again is querying a dataset with the select statement and filling up a table with the results. Im not exactly connecting to my DB because I already filled a dataset locally.
——Edit ——
I really just need a way to create an array of data rows from a query of two tables.
You could use this extension method here which i’ve written from scratch recently for another question. It enables to merge multiple tables by a common key. If no key is specified it will just use the default
DataTable.Mergemethod:You can call it in this way:
Edit: If you don’t need a new
DataTablewith the merged schema you could also useLinq-To-DataSet(now VB.NET):