0

Condition :

I have 2 tables HISTORY1 and HISTORY2, those tables has the same columns but different data.

And i'm using these code below to retrieve data from database to bindingsource

dim da =new sqldataadapter
dim ds =new dataset
dim bs =new bindingsource
dim bs2 = new bindingsource

da.SelectCommand = "select * from HISTORY1"
da.fill(ds,"HISTORY1")
bs.datasource=ds.tables("HISTORY1")

And Then i add another table to bs2

da.selectcommand="select*from HISTORY2"
da.fill(ds,"HISTORY2")
bs2.datasource=ds.tables("HISTORY2")

Problem :

Now, i want to copy every single data from HISTORY2 to HISTORY1 table.


Question :

  1. Can i update HISTORY1 from bs2?
  2. Is there any easier way to retrieve data from database to bindingsource?
Arvid Theodorus
  • 443
  • 2
  • 9
  • 20

1 Answers1

0

You should find what you want by searching "DataTable Merge"

here's a link on how to do it : http://vb.net-informations.com/dataset/dataset-merge-tables-sqlserver.htm

How it works :

Fill your dataTable With History1 like usual.

Change your select command to get the same table structure from your second table (History2),

Fill Again, the same dataSet but an other Table.

myDataSet.Tables(0).merge(myDataSet.Tables(1))

TADA!

Ludovic Migneault
  • 140
  • 1
  • 4
  • 19