473,398 Members | 2,188 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,398 software developers and data experts.

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 3388
Hello,

"Jean-Yves" <je******@gmx.net> 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
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...
2
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...
31
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...
0
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...
10
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...
2
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...
2
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...
4
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...
8
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...
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
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...
0
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,...
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
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,...
0
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...

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.