RE: Adding Data Row, where one parameter refrences a parent table.

aarond1990

New member
Joined
Jan 2, 2009
Messages
1
Programming Experience
1-3
RE: Adding Data Row, where one parameter refrences a parent table.

Hi there,
I hope this is in the correct place, as I'm new here!

Okay, so the problem i'm having is as follows.

I have a database (MS Access 2008) and a windows forms applicaltion (VB.NET 2008 SP3.5)

Two of the tables are 'Vehicle' and '2Owner'. The relationship is one-many, where one owner can appear in many vehicles - showing which department owns the vehicle.

Heres the problem:
I've got all the validation and presence checks in place etc, and have got to the add new row command, but the final parameter is asking for
parentOwnerRowByOwnerVehicle As Vehicle_Management.VehicleManagement_DataSet.OwnerRow

I know this should be a simple answer so I hope I've explaied it well enough.
For completeness I've added the surrounding code block.
Many thanks.
Aaron

VB.NET:
Try
                            selectedOwner = 1
                            For i = 0 To OwnerDataGridView.RowCount() - 2
                                If StrComp(OwnerDataGridView.Rows(i).Cells(1).Value, boxOwner.SelectedItem.ToString) = 0 Then
                                    selectedOwner = OwnerDataGridView.Rows(i)
                                End If
                            Next
                            Vehicle_ManagementDataSet.Vehicle.AddVehicleRow(txtRegistration.Text, txtMilesService.Text, DateService.Text, DateTax.Text, DateMOT.Text, txtMake.Text, txtModel.Text, "Owner-ROW-HERE")
                            Me.Validate()
                            Me.VehicleBindingSource.EndEdit()
                            Me.TableAdapterManager.UpdateAll(Me.Vehicle_ManagementDataSet)


                        Catch ex As Exception
                            MsgBox("There has been an error adding this to the database " & _
                                    ex.ToString, MsgBoxStyle.Information, "Error adding to the database")
                        Finally
                            frmVehicle.cboRegistration.Items.Clear()
                            For i = 0 To VehicleDataGridView.RowCount() - 2
                                frmVehicle.cboRegistration.Items.Add(frmVehicle.VehicleDataGridView.Rows(i).Cells(0).Value)
                            Next
                            Me.Close()
                        End Try
 
I did this in similar case yesterday, hope you see the relation:
VB.NET:
Dim arow As DBDataSet.ArtistRow = CType(CType(Me.ArtistBindingSource.Current, DataRowView).Row, DBDataSet.ArtistRow)
Me.DBDataSet.CD.AddCDRow(album, ur, arow, CShort(Date.Now.Year))
 
Back
Top