Error with "merge" or "select"

witzulu

Member
Joined
Jul 3, 2004
Messages
20
Programming Experience
3-5
Error with "merge" or "select" [RESOLVED]

Hi

I have a datagrid with that is bound to a dataset(dsFiltered) and a second dataset that contains all my records.

What I want to do is when you type in a word in a textbox(txtsearch) and click a button the dsfiltered dataset must be filled with a "filtered" version of dsALL

The databinding is as follows
VB.NET:
		 dgAll.DataSource = dsFiltered
		 dgAll.DataMember = dsFiltered.Extend.TableName.ToString

And the code that runs whenI press the button is:

VB.NET:
Try
	dsFiltered.Extend.Clear()
	dsFiltered.Merge(dsAll.Extend.Select("fullname like '%" & txtSearch.Text & "%'"))

Catch ex As Exception
   MsgBox(ex.Message)
End Try

This works fine the first time I run the code but when I click the button a second time I get the following ERROR :

An Unhandled exception of type 'System.Data.RowNotInTableException' occurred in system.windows.forms.dll

Additional Information:This row has been removed from a table and does not have any data. BeginEdit() will allow creation of new data in this row.
 
Last edited:
Hey Witzulu,

I'm afraid I'm not up on merging datasets, however if having the second dataset 'dsFiltered' isn't vital then I would create a new DataView, point it at the Extend table, and bind the datagrid to that. You can then set it's 'rowfilter' property as "fullname like '%" & txtSearch.Text & "%'", and the datagrid should immediately reflect the search.
 
As BadgerByte says, don't use two DataSets. In fact, if you only have one table then don't use a DataSet at all. You only need one DataTable or DataSet and then use the RowFilter property of the table's DefaultView, which is a DataView.

With regards to DataSets and DataTables, using a DataSet with one DataTable is like creating an array with just one element. it simply adds another layer of complexity, except it's much worse than the array because the overhead is much greater. Unless you need to include DataRelations, I recommend using stand-alone DataTables rather than a DataSet for three tables or fewer.
 
Back
Top