Hello and thanks for any help you may offer me in advance.

I using vb.net vs2008.

I have a datagridview and two datatables.
I am comparing the information in the two datatables. Now, if the data exists is datatable2 but does not exist in datatable 1 I would like to add a row to the bottom of the datagridview and fill in the necessary information.

Can someone give me an idea of the necessary syntax that I will need to accomplish this goal?
Also, I know this post is a little vague and if more information is needed to answer the problem I can give it.

Thanks,
Jessica

Recommended Answers

All 3 Replies

Hi,
Do you want to create a blank record for the user to Edit each time a non matching item is in Table 2?
Where are you actually populating the datagrid from? Table 1? A query run on both?
Maybe you could post what code you have just now?

The datagrid is being populated from table 1. If an item is in table 2 and not in table 1 I want to be able to add the record to the bottom of table 1.

Are the same fields in each table?
Or are they different?
For tables being the same:

sub CopyData(byref Tbl1 as datatable, byref Tbl2 as datatable)
dim i as integer
Dim DataItems() as object

'clear Tbl2
Tbl2.rows.clear

for i = 0 to Tbl1.rows.count-1
 'populate Array with row items
  DataItems = Tbl1.rows(i).ItemArray
  Tbl2.rows.add(DataItems)
next
Datagrid1.datasource = Tbl2
Datagrid1.databind
end sub

For the different values then put just the appropriate data into the item array.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.