Fire Hand
Fire Hand

Reputation: 26346

binding different tables from DB into gridview!

how do i dynamically bind different tables from DB with different columns into gridview?

Actually, i was using OleDbDataAdapter to to join the SQL statement and put in a DataTable but my question is, let says, i execute 1st SQL statement and when i execute 2nd SQL statement, the data adapter will use back the 1st SQL statement. So, i was thinking how to make the data adapter to clear off the 1st SQL statement before executing the 2nd statement???

Upvotes: 0

Views: 1503

Answers (2)

JBrooks
JBrooks

Reputation: 10013

You always have dtbl1.Merge(dtbl2);

Upvotes: 0

Jamie Ide
Jamie Ide

Reputation: 49251

Here are three possible solutions from easiest to hardest:

  1. Join the tables in a view and select against the view for your data source.
  2. Join the tables in a SQL statement and use that as your data source.
  3. Create a new bindable collection (probably a DataTable) and dynamically add data from the two tables to it. Use that as your data source.

Upvotes: 2

Related Questions