By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,742 Members | 1,224 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,742 IT Pros & Developers. It's quick & easy.

Datagridview - Writing Journal Transactions for a Datagridview

P: n/a
I would like to write transaction activity to a journal table, specifying
Add, Update, or Delete and some information regarding each transaction when a
user works in a datagridview.

I have tried:

Dim deletedChildRecords As dsVersaPress.RoutingDataTable = _

CType(DsVersaPress.Routing.GetChanges(Data.DataRow State.Deleted),
dsVersaPress.RoutingDataTable)

Dim newChildRecords As dsVersaPress.RoutingDataTable = _
CType(DsVersaPress.Routing.GetChanges(Data.DataRow State.Added),
dsVersaPress.RoutingDataTable)

Dim modifiedChildRecords As dsVersaPress.RoutingDataTable = _

CType(DsVersaPress.Routing.GetChanges(Data.DataRow State.Modified),
dsVersaPress.RoutingDataTable)

Try
If deletedChildRecords IsNot Nothing Then
Dim hCount As Integer
Dim hOperation As String
Dim hOperDesc As String
Dim hDeleteRecCount As Integer = deletedChildRecords.Count
For hCount = 0 To hDeleteRecCount - 1
hItemNo = deletedChildRecords.Rows(hCount)("Operation")
hOperation = deletedChildRecords.Rows(hCount)("Operation")
hOperDesc = deletedChildRecords.Rows(hCount)("OperDesc")
Next

RoutingTableAdapter.Update(deletedChildRecords)

End If

If newChildRecords IsNot Nothing Then

Dim hNewRecCount As Integer = newChildRecords.Count
RoutingTableAdapter.Update(newChildRecords)

End If

If modifiedChildRecords IsNot Nothing Then

Dim hModifiedRecCount As Integer = modifiedChildRecords.Count
RoutingTableAdapter.Update(modifiedChildRecords)
End If

DsVersaPress.Routing.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

This isolates the Insert, Delete, and Update tranactions ; but I can not
access deletedChildRecords rows and individual fields. Is there a way to do
this?

Nov 1 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.