C
Curious Trigger
Hi NG,
in my asp.net page a DetailView-Control is bound to a DataSource-Control
with select, insert, update and delete-commands configured.
As long as I type valid data into the DetailView all works perfect: records
get updated, inserted, deleted without any errors.
But if I try to add a record wich offends referential integrity rules
defined in the SQL Server 2005 database, the record will not be inserted
(which is ok, otherwise the data's integrity would be hurt), but in the
asp.net page I cannot get this infomation: data could not be inserted. I
tried hooking up the event GridView.Inserted() and DataSource.Inserted()
both with no luck.
What I am missing here? Any attribut to set on either the gridview- or
datasource-control to get those errors reported?
Here is my code for the Inserted-Event of the DataSource-Control:
* e.AffectedRows is always -1, even if the record is inserted into the table
* e.Exception is always Nothing, even if the record is NOT inserted into the
table
Protected Sub dsKpiReportService_Inserted(ByVal sender As Object, ByVal
e As System.Web.UI.WebControls.SqlDataSourceStatusEventArgs) Handles
dsKpiReportService.Inserted
Trace.Write(e.AffectedRows)
If e.Exception IsNot Nothing Then
mValid = False
Me.panWarnings.Visible = True
Me.lstWarnings.Items.Add("Error: this service could not be
inserted: " & e.Exception.Message)
e.ExceptionHandled = True
End If
End Sub
in my asp.net page a DetailView-Control is bound to a DataSource-Control
with select, insert, update and delete-commands configured.
As long as I type valid data into the DetailView all works perfect: records
get updated, inserted, deleted without any errors.
But if I try to add a record wich offends referential integrity rules
defined in the SQL Server 2005 database, the record will not be inserted
(which is ok, otherwise the data's integrity would be hurt), but in the
asp.net page I cannot get this infomation: data could not be inserted. I
tried hooking up the event GridView.Inserted() and DataSource.Inserted()
both with no luck.
What I am missing here? Any attribut to set on either the gridview- or
datasource-control to get those errors reported?
Here is my code for the Inserted-Event of the DataSource-Control:
* e.AffectedRows is always -1, even if the record is inserted into the table
* e.Exception is always Nothing, even if the record is NOT inserted into the
table
Protected Sub dsKpiReportService_Inserted(ByVal sender As Object, ByVal
e As System.Web.UI.WebControls.SqlDataSourceStatusEventArgs) Handles
dsKpiReportService.Inserted
Trace.Write(e.AffectedRows)
If e.Exception IsNot Nothing Then
mValid = False
Me.panWarnings.Visible = True
Me.lstWarnings.Items.Add("Error: this service could not be
inserted: " & e.Exception.Message)
e.ExceptionHandled = True
End If
End Sub