DataSource does not show exception if insert fails

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,743
Latest member
WoodrowMea

Latest Threads

Top