473,663 Members | 2,800 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DeleteCommand in SqlDataSource using DetailsView

16 New Member
DeleteCommand in SqlDataSource using DetailsView

Hi guys,
Figure that:
- I have two related tables by IDName:
1 - table Name (fields: IDName, Name)
2 - table Products (fields: IDProduct, IDName, Product)

On the page I have a DetailsView for inserting data on table Name and a GridView for editing and deleting records. In table Name, deleting and editing are ok but if I have a reference of IDName in table Product the deleting send me an error
---------------------------------------------
The DELETE statement conflicted with the REFERENCE constraint "FK_Produto_Fab ricante". The conflict occurred in database "JanainaPapelar ia", table "dbo.Produt o", column 'fabCodigo'.
The statement has been terminated.
---------------------------------------------

Does anyone know how to treat this so when a record in table Name has a reference record in table Products the DeleteCommand of the SqlDataSource doesn´t trigger?

thanks a lot
Oct 25 '07 #1
1 1802
kenobewan
4,871 Recognized Expert Specialist
One way would be a try catch block, but if you provide more information an expert may suggest a more elegant way.
Oct 25 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1020
by: Stu | last post by:
I have a GridView that pulls straight from a table. This uses SqlDataSource1. SqlDataSource2 grabs data from the same table, but only 1 row to fill a DeatilsView, this SqlDataSource2 uses a ControlParameter to get the SelectedValue from the initial GridView to isolate the 1 row. My question is this: in the DetailsView, a column of data is returned that I would like to use to send as a parameter to a 3rd SqlDataSource, how do I do this?
2
1587
by: stuart.d.jones | last post by:
Hi, I'm using a detailsview control with an SqlDataSource control. My Update query isn't working, and I've narrowed it down to the optimistic concurrency parameters - i.e. when I comment them out of the query, it works. What seems to be happening is that if a field is NULL when it is read in through the select statement, it's causing the update statment not to find a match. I've got ConvertEmptyStringToNull not set (so it should...
0
3163
by: Steven Blair | last post by:
I have written a simple application allowing me to update a table in my Database using a GridView, DetailsView and two SQLDataSources. Using this method, I wrote no code and my select, insert, update and delete code was written for me. I would like to use a ObjectDataSource to achieve the same results, but the only way I see of doing this is by passing in each parameter of my DetailsView into a Insert method, then either building the...
2
7336
by: phil | last post by:
Hi, The connection and DeleteCommand of a gridview are defined in the aspx file like this: <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\mydb.mdb" ProviderName="System.Data.OleDb" DeleteCommand="delete from mytable where = @nr" > </asp:SqlDataSource>
3
9241
by: Asaf | last post by:
Hi, I have SqlDataSource control that makes a "select count" to show how many rows there are in a Table and it is working fine on first page load. The problem is that when I am inserting a new row to the database table at the same ASPX page the rows count from the SqlDataSource remain the same. To refresh the SqlDataSource I have used his Select(DataSourceSelectArguments.Empty) but no luck.
0
1476
by: jobs | last post by:
Gridview with datasoure with deletecommand. Why do I need an event handler? Isn't this enough? I know this code has worked when I use a fielditemtemplate <asp:GridView ID="RouteGridView" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="RouteId,DestId"
1
4269
by: Corey B | last post by:
I have a page with a DetailsView control and a SQLDataSource control. The SQLDataSource control is connected to an Access database. Everything works fine. Now I want to change the back end database from Access to SQL Server. So I go in to the SQLDataSource and modify it to connect to the SQL Server database. No problem. However, the DetailsView control does not seem to pick up the changes. When I click on the little shortcut menu (not...
0
993
by: Luke Graham | last post by:
hi, I'm coding a social network style application for my dissertation and am having a few problems, I'm using ASP.net and VB.net I have a button within a DetailsView control that I want to trigger an Insert for a Datasource that is also within the DetailsView There is an OnClick event handler for the button but I'm having problems finding the datasource to trigger it the code I'm using is Dim DataSource As SqlDataSource =...
2
5504
by: makennedy | last post by:
Hi Experts, Please help, I am a newbie to ASP.NET 2.0 may be I am doing something wrong or there may be a bug somewhere. Basically I have a TreeView Control which I have created programmatically. And I want to bind the selection of a TreeNode (which is a record) from the database) to a DetailsView which shows the datatable record for the selected TreeView node in the Details View. I am using IDE : Visual Web Developer 2005 Express; OS=...
0
8436
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8345
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8858
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8771
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8548
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7371
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6186
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4182
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4349
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.