Search code examples
vb.netdatagridviewdataadapter

Fill two datagridviews from one tableadapter


Is it possible to fill two DataGridView (named as Datagridview1 & Datagridview2) from one dataset < one tableadapter < 2 Different queries

From query 1 = DGV1 i need to fill datagridview1
From query 2 - DGV2 i need to fill datagridview2

enter image description here


Solution

  • Is it possible? Of course, that's the glory of bound datasets. Set up your 2 queries using the DataSet designer (.xsd) by right-clicking on your TableAdapter-->Add Query --> etc.

    With two DataGridViews, you will need 2 instances of the same tableadapter (you can drag and drop from the Toolbox). Call your FillBy method (or whatever you named them) for each query, connecting the DGV data source to the correct TableAdapter (I just add a numerical suffix for simplicity).