Finding type of data row

  • Thread starter Thread starter John
  • Start date Start date
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
 
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
 
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
 
Back
Top