473,406 Members | 2,404 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

DataSource does not show exception if insert fails

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.SqlDataSourceStatusEvent Args) 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

Sep 23 '06 #1
0 1258

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Eric Lilja | last post by:
Hello, I'm working with a hash table that is encapsulated in a class. One of its member functions insert() throws an exception if the insertion fails (for example, if the value was already present...
1
by: Ricardo | last post by:
Ok, the new .net 2.0 allows us to bind a server control to a data source without writing a line of code. Now, what happens if there is a problem accessing the data source and an exception is...
4
by: Mario Sobral | last post by:
Hi ! I have written an Add-In to use in VS.NET 2003. The Add-In asks the user for a public key on a small form, and then basically goes through a selected project, looking for public...
2
by: Kelly | last post by:
I'm fairly new to ASP.NET2, but I have an ASP 3.0 background, and I've been experimenting with the DataSource and FormView widgets. I wound up having some questions along the way which I hope you...
0
by: Kevin | last post by:
Hi my name is Kevin can someone help me with the objectdatasource, when binding bussines objects to it ? i can normally bind them to a grid and detail grid but the problem remains that when the...
1
by: WhiteWizard | last post by:
First my apologies, this may be longer than the normal question. I have a windows app (.NET 2.0, VS2005), and I've written a user control that will allow the user to "drag and drop" a directory...
3
by: Deere | last post by:
I have a gridview where I was using datasource="sqldatasource1". I deleted it to use code behind. I then wanted to go back to datasource so I typed back in datasource="sqldatasource1" but now...
1
by: weird0 | last post by:
I am assigning an arrlist to the datasource property of the datagridview. In short, i want to update the datagridview. But the moment, i assign it. The application crashes. It does not display the...
9
pod
by: pod | last post by:
Hello I have a form which contains several textboxes and comboboxes I am able to loop through all the controls on this form and set the value (ctl.Text) to the Textboxes but if I try to...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.