473,809 Members | 2,849 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

'Number of query values and destination fields are not same' error

When i execute the following insert query, the above mentioned error
is coming. Anything wrong in the query?
INSERT INTO ECN_1 (Old_SbPartNo, Old_PartDesc, Old_ManPartNo,
Old_Manuf, Old_Vendor, Old_RefDesi, Old_Qty,
New_SbPartNo, New_PartDesc, New_ManPartNo,N ew_Manuf, New_Vendor,
New_RefDesi, New_Qty)
select * from (select SB0014.SbPartNo , SB0014.partDesc ,
SB0014.mANpARTn O, SB0014.manufact urer,
SB0014.vendor, sb0014.refdesi, sb0014.qty,
SB0014_2.SbPart No, SB0014_2.partDe sc, SB0014_2.mANpAR TnO,
SB0014_2.manufa cturer, SB0014_2.vendor ,
sb0014_2.refdes i, sb0014_2.qty
from SB0014 LEFT OUTER JOIN SB0014_2
on SB0014.SBPARTNO = SB0014_2.SBPART NO
where sb0014_2.SbPart No is null
or sb0014.partDesc <> sb0014_2.partde sc
or sb0014.manpartn o <> sb0014_2.manpar tno
or sb0014.manufact urer <> sb0014_2.manufa cturer
or sb0014.vendor <> sb0014_2.vendor
or sb0014.refdesi <> sb0014_2.refdes i
or sb0014.qty <> sb0014_2.qty
union all
select null, null, null, null, null, null,null,
sb0014_2.SbPart No, SB0014_2.partDe sc, SB0014_2.mANpAR TnO,
SB0014_2.manufa cturer,
SB0014_2.vendor , sb0014_2.refdes i, sb0014_2.qty
from sb0014
right outer join sb0014_2 on sb0014.SbPartNo = sb0014_2.SbPart No
where sb0014.SbPartNo is null) as u

When i execute it, it is giving me following error.

"java.sql.SQLEx ception: [Microsoft][ODBC Microsoft Access Driver]
Number of query v
alues and destination fields are not the same."

I checked the number of fields in table ECN_1 and query values which
seems to be same ie. 14. Pls let me know if there is anything wrong in
the above query.
Nov 13 '05 #1
2 8148
I think it would be easier for you to create your union query first and
then create your insert into query. My code for one that works for me
is below, you definately want your fields to match up otherwise you'll
get an error, they don't have to be the same name but they have to
match up column wise.

My Insert Into Code (this is inserting using my union query)

INSERT INTO test ( ParaLine, [Position], [Section], MOSAOC, ASI1, ASI2,
Grade, Auth, MaleFemale )
SELECT qryMTOE.ParaLin e, qryMTOE.Positio n, qryMTOE.Section ,
qryMTOE.MosAoc, qryMTOE.ASI1, qryMTOE.ASI2, qryMTOE.Grade,
qryMTOE.Auth, qryMTOE.MaleFem ale
FROM qryMTOE;

My Union Query Code:

SELECT qryMTOEenlisted .ParaLine, qryMTOEenlisted .Position,
qryMTOEenlisted .Section, qryMTOEenlisted .MosAoc, qryMTOEenlisted .ASI1,
qryMTOEenlisted .ASI2, qryMTOEenlisted .Grade, qryMTOEenlisted .Auth,
qryMTOEenlisted .MaleFemale
FROM qryMTOEenlisted ;
UNION

SELECT qryMTOEofficer. ParaLine, qryMTOEofficer. Position,
qryMTOEofficer. Section, qryMTOEofficer. MosAoc, qryMTOEofficer. ASI1,
qryMTOEofficer. ASI2, qryMTOEofficer. Grade, qryMTOEofficer. Auth,
qryMTOEofficer. MaleFemale
FROM qryMTOEofficer

UNION SELECT qryMTOEwarrant. ParaLine, qryMTOEwarrant. Position,
qryMTOEwarrant. Section, qryMTOEwarrant. MosAoc, qryMTOEwarrant. ASI1,
qryMTOEwarrant. ASI2, qryMTOEwarrant. Grade, qryMTOEwarrant. Auth,
qryMTOEwarrant. MaleFemale
FROM qryMTOEwarrant;

Notice how everything lines up with all my columns, make sure yours
does. I'm not an expert I just know how to get a lot of it to work.

Nov 13 '05 #2
Thank you for the answer. I eliminated 'select * ' after Insert
statement and now that error is gone. But facing java.sql.SQLExc eption
: General error

Don't know how to fix. I don't know how to run this query in Ms Access
2000. Else i might have first checked there whether it's working or not
and then included in my JSP code.

My query looks like this.

INSERT INTO ECN_1 (Old_SbPartNo, Old_PartDesc, Old_ManPartNo,
Old_Manuf, Old_Vendor, Old_RefDesi, Old_Qty,
New_SbPartNo, New_PartDesc, New_ManPartNo,N ew_Manuf, New_Vendor,
New_RefDesi, New_Qty)

select SB0014.SbPartNo , SB0014.partDesc , SB0014.mANpARTn O,
SB0014.manufact urer, SB0014.vendor, sb0014.refdesi, sb0014.qty,
SB0014_2.SbPart No, SB0014_2.partDe sc, SB0014_2.mANpAR TnO,
SB0014_2.manufa cturer, SB0014_2.vendor , sb0014_2.refdes i, sb0014_2.qty
from SB0014 LEFT OUTER JOIN SB0014_2
on SB0014.SBPARTNO = SB0014_2.SBPART NO
where sb0014_2.SbPart No is null
or sb0014.partDesc <> sb0014_2.partde sc
or sb0014.manpartn o <> sb0014_2.manpar tno
or sb0014.manufact urer <> sb0014_2.manufa cturer
or sb0014.vendor <> sb0014_2.vendor
or sb0014.refdesi <> sb0014_2.refdes i
or sb0014.qty <> sb0014_2.qty

union all

select null, null, null, null, null, null,null,
sb0014_2.SbPart No, SB0014_2.partDe sc, SB0014_2.mANpAR TnO,
SB0014_2.manufa cturer, SB0014_2.vendor , sb0014_2.refdes i, sb0014_2.qty

from sb0014
right outer join sb0014_2
on sb0014.SbPartNo = sb0014_2.SbPart No
where sb0014.SbPartNo is null

Nov 13 '05 #3

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

Similar topics

21
43081
by: Gavin | last post by:
Hi, I'm a newbie to programming of any kind. I have posted this to other groups in a hope to get a response from anyone. Can any one tell me how to make my VB program read the Bios serial number (or would HDD be better, or both?) and put that info into VB prog so the program won't work on another computer. My program uses an MSAccess table. Much appreciated if you can help! Thanks
3
3719
by: CSDunn | last post by:
Hello, I have a situation with MS Access 2000 in which I need to display report data in spreadsheet orientation (much like a datasheet view for a form). If you think of the report in terms of what a spreadsheet might show, the column names will actually be dynamic, based on data from a SQL Server 2000 database. The row data will also come from the same database. So in this case, I will have a main report and a subreport. I've already tried...
6
29946
by: Martin Lacoste | last post by:
Ok, before I headbutt the computer... don't know why when I add criteria in a query, I get an 'invalid procedure call'. I also don't know why after searching the help in access, the various access newsgroups, the access support centre, I can seem to find no similar situation. I am not using any references, or VBA at all in the first place. I am trying to set up a simple (or so I thought) query to work with the text of two tables. ...
19
2149
by: cover | last post by:
Is there a restriction to the number of fields you can work with in a PHP to MySQL connection? I'd used as many as 15 quite a few times and now I have a form with 34 fields and can't seem to get the info inserted into the table even though I'm not getting any connection errors, etc. Since my method is identical, I'm wondering if there's some 'rule' I am unaware of. TIA
3
6910
by: JDiamond | last post by:
Hi, I have a table called Hosts. The Hosts table contains the following fields: Each field represents a step in the project. The tech that completes each step initials the respective columns using a combo box within a form. These initials are stored in an engineer table in which the combo
9
3374
by: Kosmos | last post by:
I'm getting this error message: Number of query values and destination fields are not the same. This is the code: INSERT INTO tblDateDifference ( DateDifference ) SELECT tblContracts.EndDate As EndDate, IIf( > EndDate, DaysToCompletion(EndDate), DaysCompleted(EndDate)) AS DateDifference, FROM tblContracts; Can someone please tell me why I'm getting this error message? PLEASE?!?! lol
2
5915
by: cypriot | last post by:
Hi. I am developing an application program in java. I use MsAccess for keeping data. I had a problem with sql insert method. public void AddPatient() { String no= numberinput.getText();
1
2068
by: liorjj | last post by:
Hi All, I'm trying to insert record to Access DB to a tbale that contains its first field as AutoNumber field using the following command: "INSERT INTO Threads VALUES (" + category + "')"; And it gives me the following error: "Number of query values and destination fields are not the same". As far as I'm understand I don't need to add the first field because it's AutoNumber, So why this error is always appearing?
5
6480
by: jaishu | last post by:
Hi , I am using a form based on a query. The form is locked and the fields are not editable, but when i just tried typing something, the contents on the form didnt change, but when i closed and opened the Form again, it came up with this error "Query must have atleast one destination field", i had been coming across this error several times and could not find a solution, typically i just pasted the query and it would be fine as long as i...
0
9603
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
10643
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
9200
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
7664
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
5550
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
5690
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4333
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 we have to send another system
2
3862
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3015
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.