DataTable Fill from two Source Tables does it Append ?

  • Thread starter Thread starter mosscliffe
  • Start date Start date
M

mosscliffe

I have two tables containing similar data but from different sources.

I would normally use a UNION statement to create my SELECT statement,
but because I have Access Memo fields, these get truncated at 255
characters, if I use Union. This was a nightmare to discover why it
was truncating, sometimes and not others. I never realised it was the
UNION causing the problem.

I am wondering if i can get around this by doing a separate SELECT for
each table. I have an OleDBDataAdapter, which I use to fill a
DataTable.

The question is will the Second Fill, overwrite the first Fill or Merge
with it or Append. I need to Append.

Any advice gratefully received
 
You can call fill twice and provided your schema is the same, you will
append.

Basically, you do this...

DataTable dt = new DataTable();
Adapter1.Fill(dt);
Adapter2.Fill(dt);

As long as the schemas match (column names /types to be precise), it'll just
append them on.

Is this what you're asking?
 
That is what I was hoping - thanks.

I thought I had read somewhere, there could be problems if certain
columns had duplicate entries. It is unlikely all columns will be
duplicated, but some columns could have duplicates.

At least I know the principle is correct and I can now create tests, to
confirm it - thanks
 
Back
Top