473,320 Members | 1,900 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,320 software developers and data experts.

Child record won't add but parent exists

1,271 Expert 1GB
Working on an VB/ASP website in Visual Studio 2008. Getting the error "You cannot add or change a record because a related record is required in table 'abc'

It is true that table xyz (the target of the INSERT) is in a parent-child relationship with table abc. The PK in abc is a column RequestID_lng. The FK column in xyz is also named RequestID_lng

This is the only relationship these 2 tables are in.

I am trying to add a row in xyz with a value of 45 in the FK. There is already, previous to this action, a row in table abc with a value of 45 in the PK. So the parent already exists for this child.

I have used the watch window to copy my SQL code for the INSERT query that is being executed. I pasted that code into a new query in the Access DB and executed it without problem - it actually added the row that .Net should have.

Here is the SQL

Expand|Select|Wrap|Line Numbers
  1. INSERT INTO XYZ_tbl ( RequestID_lng, Result_str, Score_int, Sub1_str )  SELECT 45 AS Expr1, 'VVIRGINIA' AS Expr2, 30 AS Expr3, 'V -> VV ' AS Expr4 
Here is the connection string
"provider=Microsoft.Jet.OLEDB.4.0;data source = R:\Backups\Access\MY_DB.mdb"

And the activating code
Expand|Select|Wrap|Line Numbers
  1. Dim ConnectionString As New OleDbConnection(strCon2)
  2.  Dim command As New OleDbCommand(strSQL, ConnectionString)
  3.  connectionString.Open()
  4.  command.ExecuteNonQuery()  ' error occurs here
  5.  connectionString.Close()
Why would .Net give me this error?

Jim
Jul 13 '11 #1
1 1803
jimatqsi
1,271 Expert 1GB
I have found the problem. I was too clever by half. I moved my database, didn't delete the original and the program was connecting to the old copy, so no parent really existed.
Jul 14 '11 #2

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

Similar topics

4
by: news.online.no | last post by:
In a query, I need too be able to show if a parent record has a child record. Using the query in a combo box too select record in a form. Thanks :)
1
by: tdmailbox | last post by:
I have added search buttons to some access fomms. I have a seach button in both the parent and the child form. My issue is that when I search for a last name in the last_name field of the...
8
by: al | last post by:
Greetings, If I instansiate child forms in MDI parent, what is the way to close them. I can't find an event related to child to do such task. I want to close 3 child forms, all in the same...
2
by: Susan Sullivan | last post by:
How can I change properties of a child form through a parent form? I have a child form with a rich text box. I want to control font properties of the rich text box through a menu on the parent...
0
by: ILCSP | last post by:
Hello, I have a VB.Net project where I have created a dynamic menu. This menu has 2 parents (File and Edit) and I need to place 3 child submenus under Edit at runtime. The problem is that I am...
2
by: Catch_22 | last post by:
Hi, I have a stored procedure that has to extract the child records for particular parent records. The issue is that in some cases I do not want to extract all the child records only a...
2
by: javanet | last post by:
Hi all, 1) i opened a parent window. 2) then i opend a child window thruogh this parent window. Now i want to close child window before closing the parend window means my clients can not be...
3
by: zacks | last post by:
Forgive me if this has been already asked an answered, I did do a search both here and in VS2005 Help, but I can't find the answer to my question. I am developing an MDI application that is a...
1
by: Bhishm | last post by:
Hi, I am opening a child window from parent using window.open, but on refreshing the parent the reference of the child is lost. Is there any way to save the reference of the child in the...
4
by: iporter | last post by:
I wonder if anyone can clear up an OOP issue for me, specifically, how to have multiple child objects of a parent object. Consider the code below: var parentObj={ childCount: 0, childObj: {...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.