Click here to Skip to main content
15,921,660 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: DataReader Pin
pmarfleet11-Jan-08 22:54
pmarfleet11-Jan-08 22:54 
Generalusing arrow keys to select different pictureboxes Pin
raventatatatata11-Jan-08 20:04
raventatatatata11-Jan-08 20:04 
GeneralRe: using arrow keys to select different pictureboxes Pin
Dave Kreskowiak12-Jan-08 7:06
mveDave Kreskowiak12-Jan-08 7:06 
GeneralRe: using arrow keys to select different pictureboxes Pin
raventatatatata12-Jan-08 16:23
raventatatatata12-Jan-08 16:23 
GeneralRe: using arrow keys to select different pictureboxes Pin
Dave Kreskowiak13-Jan-08 7:25
mveDave Kreskowiak13-Jan-08 7:25 
GeneralRe: using arrow keys to select different pictureboxes Pin
raventatatatata13-Jan-08 23:06
raventatatatata13-Jan-08 23:06 
GeneralRe: using arrow keys to select different pictureboxes Pin
Dave Kreskowiak14-Jan-08 2:00
mveDave Kreskowiak14-Jan-08 2:00 
GeneralInsert, delete & update child table (parent-child relating table) Pin
tellytub11-Jan-08 19:44
tellytub11-Jan-08 19:44 
Hi all,

I have done the following code for updating my parent table - Contract. And it works sucessfully.

Try
Me.Validate()
Me.ContractBindingSource.EndEdit()
Me.ContractTableAdapter.Update(Me.ContractContractDetailDataSet.Contract)
MsgBox("Update successful")

Catch ex As Exception
MsgBox("Update failed")
End Try
End Sub


Now, I would like to insert, delete and update for the child table - ContractDetail
Its relationship is like this.


I tried something like the following but it did not work. I tried changing some variables like ContractTableAdapter to ContractDetailTableAdapter but it did not reflect any changes on my database.


Dim deletedChildRecords As ContractContractDetailDataSet.ContractDataTable = _
            CType(ContractContractDetailDataSet.Contract.GetChanges(Data.DataRowState.Deleted), ContractContractDetailDataSet.ContractDataTable)

        Dim newChildRecords As ContractContractDetailDataSet.ContractDataTable = _
            CType(ContractContractDetailDataSet.Contract.GetChanges(Data.DataRowState.Added), ContractContractDetailDataSet.ContractDataTable)

        Dim modifiedChildRecords As ContractContractDetailDataSet.ContractDataTable = _
            CType(ContractContractDetailDataSet.Contract.GetChanges(Data.DataRowState.Modified), ContractContractDetailDataSet.ContractDataTable)

        Try
            If deletedChildRecords IsNot Nothing Then
                ContractTableAdapter.Update(deletedChildRecords)
            End If

            ContractTableAdapter.Update(ContractContractDetailDataSet.Contract)

            If newChildRecords IsNot Nothing Then
                ContractTableAdapter.Update(newChildRecords)
            End If

            If modifiedChildRecords IsNot Nothing Then
                ContractTableAdapter.Update(modifiedChildRecords)
            End If

            ContractContractDetailDataSet.AcceptChanges()

        Catch ex As Exception
            MessageBox.Show("An error occurred during the update process")
            ' Add code to handle error here.

        Finally
            If deletedChildRecords IsNot Nothing Then
                deletedChildRecords.Dispose()
            End If

            If newChildRecords IsNot Nothing Then
                newChildRecords.Dispose()
            End If

            If modifiedChildRecords IsNot Nothing Then
                modifiedChildRecords.Dispose()
            End If

        End Try
    End Sub


These are the components that are created.

Any help is greatly appreciated. Thanks!

telly
GeneralRe: Insert, delete & update child table (parent-child relating table) Pin
tellytub11-Jan-08 19:59
tellytub11-Jan-08 19:59 
GeneralParser error Pin
identy11-Jan-08 15:05
identy11-Jan-08 15:05 
GeneralRe: Parser error Pin
Dave Kreskowiak11-Jan-08 16:35
mveDave Kreskowiak11-Jan-08 16:35 
GeneralRe: Parser error Pin
Paul Conrad11-Jan-08 18:39
professionalPaul Conrad11-Jan-08 18:39 
GeneralExecuting an executable in the setup process Pin
xbiplav11-Jan-08 10:55
xbiplav11-Jan-08 10:55 
GeneralRe: Executing an executable in the setup process Pin
Dave Kreskowiak11-Jan-08 11:06
mveDave Kreskowiak11-Jan-08 11:06 
GeneralUsing the Selected value from a combo box in a database update Pin
AAGTHosting11-Jan-08 9:57
AAGTHosting11-Jan-08 9:57 
GeneralRe: Using the Selected value from a combo box in a database update Pin
Dave Kreskowiak11-Jan-08 10:33
mveDave Kreskowiak11-Jan-08 10:33 
GeneralChange Directory Pin
kermit88811-Jan-08 9:57
kermit88811-Jan-08 9:57 
GeneralRe: Change Directory Pin
Dave Kreskowiak11-Jan-08 10:31
mveDave Kreskowiak11-Jan-08 10:31 
GeneralRe: Change Directory Pin
kermit88811-Jan-08 10:42
kermit88811-Jan-08 10:42 
Generalcolor display in grid [modified] Pin
Member 476409411-Jan-08 2:58
Member 476409411-Jan-08 2:58 
GeneralRe: color display in grid Pin
Dave Kreskowiak11-Jan-08 3:54
mveDave Kreskowiak11-Jan-08 3:54 
GeneralRe: color display in grid Pin
Member 476409411-Jan-08 16:43
Member 476409411-Jan-08 16:43 
GeneralRe: color display in grid Pin
Dave Kreskowiak12-Jan-08 7:02
mveDave Kreskowiak12-Jan-08 7:02 
GeneralDoubt in DOS Pin
Senthil S11-Jan-08 2:25
Senthil S11-Jan-08 2:25 
GeneralRe: Doubt in DOS Pin
Paul Conrad11-Jan-08 2:31
professionalPaul Conrad11-Jan-08 2:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.