Union join between 2 datasets

  • Thread starter Thread starter Cor Ligthert[MVP]
  • Start date Start date
C

Cor Ligthert[MVP]

Ohad,

Although you describe completeley what you want to do, do I miss something,
you cannot set a datarow in a DataSet. You can only set datarows in
DataTables, which can residence in a DataSet.

A dataRow can only belong to one datatable, altough you can import a row in
another table.

I miss this in your description so although you describe it very well, is it
in my very difficult to help you with more then some general phrases what
maybe can help you, however more probebly will only lead you in the wrong
direction.

(It is not important where the DataTable is, in fact you can use in your
problem for the same one dataset with two tables)

Cor
 
Hi all,

I have a problem to join records from 2 datasets. Means:

I have a dataset that I fill into one table from a join between 2 DB tables.
The data that is up to date to the moment of laoding it. called DS1
Into other dataset (called DS2) that contains only on one of the tables I
used in DS1, the user inserts records from the first dataset (DS1).
I want to enable my user to refresh DS1 without saving DS2 to the database,
and to present in DS1 only the recored retrived from the DB, and not appear
in DS2.

I'll try to give an example:
I have a system that show available places on a theater.
There are two kind of places: Free ones that the user can order, and
temporary occupied - orderd but not approved permanently.
The customer log on, and retrive the list of available places (This is DS1),
and order a place (this is done by copying the row from DS1 to DS2, and
deleteing it from DS1) . At theis point, he does'nt commit the transaction.
If the user refresh DS1 (in order to retrieve up to date list of available
places because other users could order places that were available, and by
now they not), the databse dosen't know of the row in DS2, and will return
it back as available place.
My probklem is how to delete the record in DS2 from the refreshed DS1.

Is it possible?

Thaks
Ohad
 
Hi Cor

I do not set a datarow in a dataset, I create new datarow in DS2, and the
values I assign to the new row are values from DS1.
For Example:
Private Sub CreateNewRecord(ByVal drSourceDataRow As DataRow)
Dim drDataRow As DataRow
Try
drDataRow = dsHeader.Tables("lines_detailed").NewRow
drDataRow("entry_key") = txtEntryKey.Text
drDataRow("loc_a") = drSourceDataRow("loc_a")
dsHeader.Tables("lines_detailed").Rows.Add(drDataRow)
Me.BindingContext(dgPlaces.DataSource,
dgPlaces.DataMember).EndCurrentEdit()
Catch ex As Exception
HandleExceptions(ex)
End Try
End Sub

I hope that can help you help me...

Ohad
 
Ohad,
Private Sub CreateNewRecord(ByVal drSourceDataRow As DataRow)
Dim drDataRow As DataRow
Try
drDataRow = dsHeader.Tables("lines_detailed").NewRow
drDataRow("entry_key") = txtEntryKey.Text
drDataRow("loc_a") = drSourceDataRow("loc_a")
dsHeader.Tables("lines_detailed").Rows.Add(drDataRow)

The rest of your code incluiding your Try is without sense as you have
nothing that can throw an exception (outside development time). You are
setting object addresses to the new table while you have no data from
controls where the data has to been pushed down with the endcurrentedit

To remove a row from a datatable that you have retrieved from a DataBase,
you have to use one of the Delete methods. If you have build the table let
say by hand you can use the Remove methods.

By instance

drSourceDataRow.Table.Rows.Delete(drSourceDataRow).

Nicer to use the table direct of course.

Cor
 
Back
Top