473,804 Members | 3,771 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Foreign Key Violation problem ??

Hi.
I have a weird problem when I update my database.
I am using SQL Server 2000. In my VB.NET application I used Web Services for
insert, update, delete.
I have a relation between 2 tables in my database.
I use dataset to transport data to and from the server.
I use native sqlclient provider.
I have .NET Framework 1.1
I use reflexion to create objects: SqlDataAdapter, SqlCommand. All this
using interfaces like IDBDataAdapter, IDBConnection etc ....
Let me explain the case a bit clearer.

** First test on Update in my VB.NET application
I retrieve a record from the database and I edit a foreign key field with a
value does not exist in the related table. Normally it should throw an
Exception, but as incredible as it is, it updates the database thus
violating the database constraint. I checked in my database and yes there it
is. Ok I go in Enterprise Manager and put back a correct value. Still from
Enterprise manager I tried again to put a wrong value in that field and
Enterprise Manager rejects the change. That was expected.

** Second test on the same database using a VB 6.0 application
From VB. 6.0 the same test fails and I get message Violation of Foreign key
.....
Ok that normal.

** Third test on INSERT in VB.NET application
If I try to insert a record with a wrong value in the foreign key field, I
do get an Exception this time.

It seems it's just when I do an UPDATE that it bypasses the database
constraint.
Whats the problem ? Is there a problem with the DataAdapter or the
SQLCommand ??

I am getting crazy with this.
Any help and clue most welcomed.
Jean-Yves
_______________ _______________ _______________ _______________ ______ Jean-Yves
Mr ICQ#: 36608088 Current ICQ status: + More ways to contact me
_______________ _______________ _______________ _______________ ______
Nov 19 '05 #1
1 3410
Hello,

"Jean-Yves" <je******@gmx.n et> schrieb:
[...]
** Third test on INSERT in VB.NET application
If I try to insert a record with a wrong value in the foreign key field, I
do get an Exception this time.

It seems it's just when I do an UPDATE that it bypasses the database
constraint.
Whats the problem ? Is there a problem with the DataAdapter or the
SQLCommand ??


INFO: Newsgroup for .NET+database (ADO .NET) questions:

news://msnews.microsoft.com/microsof...amework.adonet

Regards,
Herfried K. Wagner
--
MVP · VB Classic, VB .NET
http://www.mvps.org/dotnet
Nov 19 '05 #2

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

Similar topics

0
4537
by: Ron | last post by:
Mandatories: Ver 7.3.4, Redhat Linux 8.0, P4, 2GB RAM I want to add a 'nullable' foreign key to a column in a table. I have tables "company" and "project" which may be related by company.companyID <-> project.companyID. project.companyID is allowed to be null. However, when someone tries to delete a company which is still referenced in "project" I want a constraint restricting deletion. I tried:
2
2246
by: reneeccwest | last post by:
There are two tables, parent and child table. Foreign key field of the child table is not a required field. If the data is submitted w/o a value into the foreign key field, what should I make it as a default value? Should it be "null"?
31
3386
by: Robert Brown | last post by:
Let's say I have a type hierarchy: (just an example) the general entity customer: CREATE TABLE customer(customer_id int, customer_name varchar(250), customer_type int) three specific customer subtypes: 1 - business, 2 - home, 3 - university
0
1418
by: Scott Ribe | last post by:
I've got a problem which I think may be a bug in Postgres, but I wonder if I'm missing something. Two tables, A & B have foreign key relations to each other. A 3rd table C, inherits from A. A stored procedure updates a row in C, adds a row each in B & C. I get an integrity violation. All the foreign keys are deferrable, and the stored procedure is called from within a transaction with constraints deferred. (And the foreign keys do refer to...
10
17867
by: D. Dante Lorenso | last post by:
I'd like to run a clean up command on my tables to eliminate rows that I'm no longer using in the database. I want to do something like this: DELETE FROM tablename WHERE IS_REFERENCED_BY_FOREIGN_KEY IS FALSE; Does anyone know how something like this could be done in PostgreSQL? I know I can search all the tables that
2
8107
by: Ev | last post by:
I have a database table in SQL Server that has a self join. In C# I have a DataTable with a self-join. I have defined a foreign key constraint on the DataTable for the self join. The AcceptRejectRule is set to Cascade Table Structure: OrderID (Identity field) OrderDesc OrderParent (this is the self-join - it is a foreign key to OrderID) In my code I add several rows to the table, createing a hierarchy of orders
2
12965
by: Tim::.. | last post by:
Can someone please tell me why I keep getting the following error from the code below! Error: INSERT statement conflicted with COLUMN FOREIGN KEY constraint 'FK_tblOfficePageContent_tblPageContent'. The conflict occurred in database 'CPNCMS', table 'tblPageContent', column 'pageID'. The statement has been terminated. I cant seem to see why I keep getting an error when I do the insert!
4
6697
by: shreedhan | last post by:
I have two tables table1 and table2 Table1 has a foreign key which references key of table2 Table2 also has a foreign key which references key of table1 Now when I try to insert into any of those 2 tables, violation of foreign key occurs. How can I insert into both tables without violating foreign key Is there any way to insert both tables simultaneously? thanks
8
3074
by: Geoff Cox | last post by:
Hello, I have been using Javascript to access some audio files from another server and there has been no associated problem with IE or FF but Opera gave an error message which led me to read that accessing files from a "foreign" domain name is a security violation for Javascript. This true? If yes, why do all above browsers allow it to happen?! The reason for putting the audio files on another server was to cope
0
9584
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
10337
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
10323
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
9160
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
7622
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
6854
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5654
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3822
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2995
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.