J
Jim
Hi,
I'm kind of in the 11th hour with this project and I'm running into an bit
of a bug with my code... I'm not sure what I'm doing wrong, but I am
calling RejectChanges so I can determine the Primary Key of some records
I've deleted. My intention is to use the Primary Key to delete related
records on other tables. Unfortunately when I use RejectChange to make the
deleted rows readable on my datagrid so I can get the primary key, I get the
following error:
"Failed to enable contraints. One of more rows contain values violation
non-null, unique, or forgeign-key constraints."
Here is a piece of the code with the error denoted with "(<---------ERROR
HERE)"... any assistance is GREATLY appreciated!!! (Sorry for any line
wrapping)
'Handle deletes
Dim tempDs2 As New Data.DataSet()
tempDs2 = DsMasterLic1.GetChanges(DataRowState.Deleted)
If Not tempDs2 Is Nothing Then
If MessageBox.Show("Deleting Agreements will remove all associated data!"
& vbCrLf & "Are you sure you want to proceed?", "WARNING - DELETING
AGREEMENT", MessageBoxButtons.YesNo, MessageBoxIcon.Warning,
MessageBoxDefaultButton.Button2) = DialogResult.Yes Then
Dim q As Long
Dim objCon As New OleDb.OleDbConnection()
Dim objCmd As New OleDb.OleDbCommand()
Dim objTrans2 As OleDb.OleDbTransaction
Try
objCon.ConnectionString = objBrwLicAgreeCon.ConnectionString
objCon.Open()
objTrans2 = objCon.BeginTransaction
objCmd.Connection = objCon
objCmd.Transaction = objTrans2
Catch ex As Exception
MessageBox.Show(ex.Message, "Connecting to Database for Agreement
Deletion", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
With tempDs2.Tables("agreementInfo")
'Make deleted rows readable
tempDs2.RejectChanges() ''(<---------ERROR HERE)
For q = 0 To .Rows.Count - 1
Dim intAgreeTempID As Int32
'''Find affected Agreement ID's
intAgreeTempID = .Rows(q).Item("agreementID")
'''BLAH BLAH BLAH - More code
'''BLAH BLAH BLAH - More code
Thanks,
Jim
I'm kind of in the 11th hour with this project and I'm running into an bit
of a bug with my code... I'm not sure what I'm doing wrong, but I am
calling RejectChanges so I can determine the Primary Key of some records
I've deleted. My intention is to use the Primary Key to delete related
records on other tables. Unfortunately when I use RejectChange to make the
deleted rows readable on my datagrid so I can get the primary key, I get the
following error:
"Failed to enable contraints. One of more rows contain values violation
non-null, unique, or forgeign-key constraints."
Here is a piece of the code with the error denoted with "(<---------ERROR
HERE)"... any assistance is GREATLY appreciated!!! (Sorry for any line
wrapping)
'Handle deletes
Dim tempDs2 As New Data.DataSet()
tempDs2 = DsMasterLic1.GetChanges(DataRowState.Deleted)
If Not tempDs2 Is Nothing Then
If MessageBox.Show("Deleting Agreements will remove all associated data!"
& vbCrLf & "Are you sure you want to proceed?", "WARNING - DELETING
AGREEMENT", MessageBoxButtons.YesNo, MessageBoxIcon.Warning,
MessageBoxDefaultButton.Button2) = DialogResult.Yes Then
Dim q As Long
Dim objCon As New OleDb.OleDbConnection()
Dim objCmd As New OleDb.OleDbCommand()
Dim objTrans2 As OleDb.OleDbTransaction
Try
objCon.ConnectionString = objBrwLicAgreeCon.ConnectionString
objCon.Open()
objTrans2 = objCon.BeginTransaction
objCmd.Connection = objCon
objCmd.Transaction = objTrans2
Catch ex As Exception
MessageBox.Show(ex.Message, "Connecting to Database for Agreement
Deletion", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
With tempDs2.Tables("agreementInfo")
'Make deleted rows readable
tempDs2.RejectChanges() ''(<---------ERROR HERE)
For q = 0 To .Rows.Count - 1
Dim intAgreeTempID As Int32
'''Find affected Agreement ID's
intAgreeTempID = .Rows(q).Item("agreementID")
'''BLAH BLAH BLAH - More code
'''BLAH BLAH BLAH - More code
Thanks,
Jim