Finding type of data row

J

John

Hi

I have below code to update data;

Try
Me.TableAdapterManager.UpdateAll(Me.MyDataSet)
Catch ex As DBConcurrencyException

End Try

The exception ex returns ex.row as the data row with concurrency issue. As
there are several tables in dataset, how can I find which table the data row
belongs to and then typecast ex.row to the relevant data table's data row
type?

Many Thanks

Regards
 
J

Jürgen Schulz

John said:
Hi

I have below code to update data;

Try
Me.TableAdapterManager.UpdateAll(Me.MyDataSet)
Catch ex As DBConcurrencyException

End Try

The exception ex returns ex.row as the data row with concurrency issue. As
there are several tables in dataset, how can I find which table the data row
belongs to and then typecast ex.row to the relevant data table's data row
type?

Many Thanks

Regards
Hi John

If there are several tables in the dataset and they are in relationship each
other(1:1 or 1:n), then you have to define the TableAdapterManager at first.

Dim dsBeispiel As New DataSetBeispiel
Dim taTable1 As New DataSetBeispielTableAdapters.Table1TableAdapter
Dim taTable2 As New DataSetBeispielTableAdapters.Table2TableAdapter
Dim tamBeispiel As New DataSetBeispielTableAdapters.TableAdapterManager
tamBeispiel.Table1TableAdapter = New DataSetBeispielTableAdapters.Table1TableAdapter
tamBeispiel.Table2TableAdapter = New DataSetBeispielTableAdapters.Table2TableAdapter
tamBeispiel.UpdateOrder = DataSetBeispielTableAdapters.TableAdapterManager.UpdateOrderOption.InsertUpdateDelete

taTable1.Fill(dsBeispiel.Table1)
taTable2.Fill(dsBeispiel.Table2)
You have to put this code in the Page_Load Event(if you use WebForms).

In the event where you save the changes you have to put
tamBeispiel.UpdateAll(dsBeispiel)

In my opinion is this code example only valid when you use strongly typed DataSets.

Take also a look at this articles http://msdn.microsoft.com/en-us/library/ms233823.aspx
http://msdn.microsoft.com/en-us/library/bb384426.aspx

Regards Juergen
 
J

John

Hi Juergen

I have the adapter manager, data adapters and dataset all set up. I need to
know what to do when a concurrency error occurs and first step seems to be
to know which table is it that has concurrency error in a multi table
scenario.

Thanks

Regards
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top