473,513 Members | 2,493 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

INSERT INTO Query Error

12 New Member
I am creating a query to find unmatched rows between a local access table and an online MS SQL Server table based on the PK field ID. This is working without any flaws. My problems start when I run a append query with INSERT INTO based on the result of the former. I get the following error:

"Database set 0 field(s) to null due to a type conversion failure and it didnt add 1 record(s) to the table due to key violations, 0 record(s)due to lock violations, and 0 record(s) due to validations rule violations...."
I have enclosed an screen dump of the error

The strange thing is that query fires normally after a while!! My other append and update queries dont have this problem, I have also a append query going in the oppisite direction, from the online SQL table to the local Access table, and this error does not show up in that case.

I have two tables for the export to the online tables, one is the parent table and a child table, I see to it that the parent table gets upploaded before the child table, I do this in a macro, could it be a problem with the parent table not being able to uploaded before the child table event fires? Is it poosible to have som time delay in between? if this could be the issue?

thanks
-Sohail
Attached Images
File Type: jpg appendQueryError.jpg (7.9 KB, 199 views)
Jun 17 '10 #1
12 2650
jimatqsi
1,271 Recognized Expert Top Contributor
Why not just add a join to the parent table in your append so if the key is not in the parent table an attempt to put it in the child table cannot be made.

Jim
Jun 17 '10 #2
lupis
12 New Member
So you think the error generated could be due the parent table not getting uppdate before the child table action event fires?
Jun 17 '10 #3
NeoPa
32,557 Recognized Expert Moderator MVP
Have you checked to see which item is failing. It will either be a key that is included twice in the query, or a key that already exists in the destination table.

The SQL may be helpful too. It's hard to work blind, and the SQL is likely to be required to get an understanding of what's wrong.
Jun 17 '10 #4
lupis
12 New Member
Hi NeoPa

"It will either be a key that is included twice in the query, or a key that already exists in the destination table."

I create first a query to see what records are in the local table and not on the remote table, I then use this query as a basis for the actual INSERT INTO query for the remote table, so a PK key does not exist previously for that record. The PK is autoincremented, inexed and does not accept duplicates.

-Sohail
Jun 17 '10 #5
NeoPa
32,557 Recognized Expert Moderator MVP
That may be true, but we are not only talking of PKs here. Any index could cause this problem. In fact one has. Without question. That's what the message is telling you.
Jun 17 '10 #6
lupis
12 New Member
So this would still commmit to the local Access table and not the remote SQL Server table?
Jun 17 '10 #7
NeoPa
32,557 Recognized Expert Moderator MVP
I don't understand the question. The record that fails would go nowhere.

As I suggested in post #4 you need to determine which record is failing. From there you may find you understand why it does so and can then decide how you think it should be working and make the relevant changes.
Jun 18 '10 #8
lupis
12 New Member
@NeoPa
Well, the record does go somewhere,it is actually saved locally but not remotely, and I am just handling two records, one for the parent table, and after that the child table so it has a valid FK of the parent table.
Jun 18 '10 #9
lupis
12 New Member
@NeoPa
Well, I got it solved finally, it was not a timing issue as I suspected. I got some good advice not to include the PK in my append query, thats what was causing the problem.

-Sohail
Jun 18 '10 #10
NeoPa
32,557 Recognized Expert Moderator MVP
I'm pleased you resolved your problem. Obviously that would have been hard for anyone here to know in the absence of the SQL I suggested you showed in my post #4. Frankly, if that's the issue then I'm surprised you got any records to add at all, but it's hard to know what's really going on from a distance, without the information to work from.
Jun 18 '10 #11
jimatqsi
1,271 Recognized Expert Top Contributor
Yes, sounds like the PK is an auto-incrementing numeric, otherwise leaving it out of the append would fail completely. But I didn't realize you could specify that value sometimes.

Jim
Jun 18 '10 #12
NeoPa
32,557 Recognized Expert Moderator MVP
I'm pretty sure you can't Jim. Sometimes we don't get all the information posted, for various reasons.
Jun 18 '10 #13

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

Similar topics

5
15395
by: Annie | last post by:
hello guys, I have little experience working with C# and MS Access ... I am having an insert query with one datetime field and a boolean and couple of text and number fields as below: ...
3
2434
by: tyngtyng | last post by:
hi... i'm new to the php and now i'm getting an error to insert my data inside the form..and also undefined index in latest_updated...... Now,i'm having trouble catching what i'm doing...
2
4787
by: technocraze | last post by:
Hi guys, I have encountered this error when updating the values to the MS Acess table. Error : Update on linked table failed. ODBC sql server error Timeout expired. MS Acess is my front end and...
6
3440
by: rn5a | last post by:
During registration, users are supposed to enter the following details: First Name, Last Name, EMail, UserName, Password, Confirm Password, Address, City, State, Country, Zip & Phone Number. I am...
2
1717
by: csharpa | last post by:
Hi, I wrote an insert query in TableAdapter and it gave me this error “Failed to get schema for this query”. The query that I wrote was this INSERT INTO STUDENT (S_ID,...
1
1217
by: kiny3k | last post by:
hi, i have written this insert query for inserting data in database : "insert into leavemaster (leave_code,leave_desc,leave_type, leave_days, leave_valid_month, leave_amount, effective_date,...
8
9384
by: Santy | last post by:
Hello All, I am new to DB2, Currently i am using DB2 version 8.02 personal edition on Windows XP Professional. And Facing problem with rowlock in insert query. I have created a sample database...
1
2750
by: Luqman | last post by:
I have created a Insert Query in Sql Data Source using Oracle Database, with the parameters, and its connected with DetailView Control. When I try to Insert through DetailView Control, Illegal...
2
4799
by: kaushalgajjar | last post by:
Hi there i have a problem in inserting a query to Access database. i am having a column which is AutoNumber and if i skip that field in insert query from vb.net then it is giving me an error "Syntax...
4
7586
by: franc sutherland | last post by:
Hello, I am using Access 2003. I am having trouble trapping the "can't append all the records in the append query" error message when appending data to a query from a table which is linked to...
0
7260
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
7384
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
7539
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
5686
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,...
1
5089
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...
0
4746
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...
0
3234
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...
0
3222
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1596
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.