Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Number of query values and destination fields are not the same.

Status
Not open for further replies.

leeboycymru

Programmer
Jan 23, 2007
185
GB
I keep getting this error:

Number of query values and destination fields are not the same.

I cant seem to find the problem, here is my code:

<% Server.ScriptTimeout = 360 %>
<%

FUNCTION fixQuotes ( theString )
fixQuotes = REPLACE( theString, "'", "''" )
END FUNCTION

set connM = server.createobject("ADODB.Connection")
connM.open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & Server.MapPath("..\db_import\EventStyle.mdb")


if instr(Trim(Request.ServerVariables("HTTP_REFERER")),"addproduct_art.asp") or instr(Trim(Request.ServerVariables("HTTP_REFERER")),"updateproduct_art.asp") then


Set Upload = Server.CreateObject("Persits.Upload")
theCount = upload.save(server.mappath("..")&"\images\uploaded")



For Each File in Upload.Files
filename = File.FileName

Next

'Count = Upload.SaveVirtual("../upload")

' Get the form variables
addProduct = TRIM (Upload.Form("addProduct"))
updateProduct = TRIM (Upload.Form("updateProduct"))
deleteProduct = TRIM (Upload.Form("deleteProduct"))

'response.write("delete=" & deleteProduct)

delID = TRIM (Upload.Form("delID"))
catID = TRIM (Upload.Form("catID"))
artTitle = TRIM (Upload.Form("artTitle"))
artCategory = TRIM (Upload.Form("artCategory"))
artBriefDesc = TRIM (Upload.Form("artBriefDesc"))
artPrice = TRIM (Upload.Form("artPrice"))
artPicFull = TRIM (filename)
artHood = TRIM (filename)
artFace = TRIM (filename)
artCaseDesc = TRIM (Upload.Form("artCaseDesc"))
artDialDesc = TRIM (Upload.Form("artDialDesc"))
artMovementDesc = TRIM (Upload.Form("artMovementDesc"))
artMakerDesc = TRIM (Upload.Form("artMakerDesc"))
artDateDesc = TRIM (Upload.Form("artDateDesc"))
artHeightDesc = TRIM (Upload.Form("artHeightDesc"))
artMoonDisplay = TRIM (Upload.Form("artMoonDisplay"))
artStatus = TRIM (Upload.Form("artStatus"))
artDisplay = TRIM (Upload.Form("artDisplay"))
origImage = TRIM(upload.Form("origImage"))
origHImage = TRIM(upload.Form("origHImage"))
origFImage = TRIM(upload.Form("origFImage"))
set upload = nothing

'response.write("CATID=" & catID)

'Assign Default Values

IF artTitle = "" THEN
artTitle = "?????"
END IF
IF artCategory = "" THEN
artCategory = "?????"
END IF
IF artBriefDesc = "" THEN
artBriefDesc = "?????"
END IF
IF artPrice = "" THEN
artPrice = "?????"
END IF
IF artCaseDesc = "" THEN
artCaseDesc = "?????"
END IF
IF artDialDesc = "" THEN
artDialDesc = "?????"
END IF
IF artMovementDesc = "" THEN
artMovementDesc = "?????"
END IF
IF artMakerDesc = "" THEN
artMakerDesc = "?????"
END IF
IF artDateDesc = "" THEN
artDateDesc = "?????"
END IF
IF artHeightDesc = "" THEN
artHeightDesc = "?????"
END IF
IF artMoonDisplay = "" THEN
artMoonDisplay = "?????"
END IF
IF artStatus = "" THEN
artStatus = "?????"
END IF
IF artDisplay = "" THEN
artDisplay = "?????"
END IF
' Add new product

if artPicFull = "" then

Pimage = origImage

else

Pimage = artPicFull

end if

if artHood = "" then

Himage = origHImage

else

Himage = artHood

end if

if artFace = "" then

Fimage = origFImage

else

Fimage = artFace

end if

if addProduct <> "" then
strsqlM = "INSERT INTO eventDisplay " &_
"( art_Title, art_Category, art_BDescription, art_Price, art_ThumbFull, art_ThumbHood, art_ThumbFace, case_Text, dial_Text, movement_Text, maker_Text, date_Text, height_Text, art_Status, art_Display, art_MoonDisplay ) VALUES (" &_
" '" & fixQuotes (artTitle ) & "', " &_
" '" & fixQuotes (artCategory ) & "', " &_
" '" & fixQuotes (artBriefDesc ) & "', " &_
" '" & fixQuotes (artPrice ) & "', " &_
" '" & fixQuotes (artPicFull ) & "' )" &_
" '" & fixQuotes (artHood ) & "' )" &_
" '" & fixQuotes (artFace ) & "' )" &_
" '" & fixQuotes (artCaseDesc ) & "', " &_
" '" & fixQuotes (artDialDesc ) & "', " &_
" '" & fixQuotes (artMovementDesc ) & "', " &_
" '" & fixQuotes (artMakerDesc ) & "', " &_
" '" & fixQuotes (artDateDesc ) & "', " &_
" '" & fixQuotes (artHeightDesc ) & "', " &_
" '" & fixQuotes (artMoonDisplay ) & "', " &_
" '" & fixQuotes (artStatus ) & "', " &_
" '" & fixQuotes (artDisplay ) & "', "


'rsuser.open strsql, conn
ConnM.Execute strsqlM

end if
%>
 
Hello,

I think I noticed that there where a few bracket issues with the bottom part of that code above. below:

if addProduct <> "" then
strsqlM = "INSERT INTO eventDisplay " &_
"( art_Title, art_Category, art_BDescription, art_Price, art_ThumbFull, art_ThumbHood, art_ThumbFace, case_Text, dial_Text, movement_Text, maker_Text, date_Text, height_Text, art_Status, art_Display, art_MoonDisplay ) VALUES (" &_
" '" & fixQuotes (artTitle ) & "', " &_
" '" & fixQuotes (artCategory ) & "', " &_
" '" & fixQuotes (artBriefDesc ) & "', " &_
" '" & fixQuotes (artPrice ) & "', " &_
" '" & fixQuotes (artPicFull ) & "', " &_
" '" & fixQuotes (artHood ) & "', " &_
" '" & fixQuotes (artFace ) & "', " &_
" '" & fixQuotes (artCaseDesc ) & "', " &_
" '" & fixQuotes (artDialDesc ) & "', " &_
" '" & fixQuotes (artMovementDesc ) & "', " &_
" '" & fixQuotes (artMakerDesc ) & "', " &_
" '" & fixQuotes (artDateDesc ) & "', " &_
" '" & fixQuotes (artHeightDesc ) & "', " &_
" '" & fixQuotes (artMoonDisplay ) & "', " &_
" '" & fixQuotes (artStatus ) & "', " &_
" '" & fixQuotes (artDisplay ) & "' )"

But after sorting that out (I think) i now have a different error, this time its:

Microsoft JET Database Engine error '80040e07'

Data type mismatch in criteria expression.


lee
 
Display and moondisplay are both numeric condiditons, so was wondering if it could be that

lee
 
Hi

I changed it to this, having looked into that

if addProduct <> "" then
strsqlM = "INSERT INTO eventDisplay " &_
"( art_Title, art_Category, art_BDescription, art_Price, art_ThumbFull, art_ThumbHood, art_ThumbFace, case_Text, dial_Text, movement_Text, maker_Text, date_Text, height_Text, art_Status, art_Display, art_MoonDisplay ) VALUES (" &_
" '" & fixQuotes (artTitle ) & "', " &_
" '" & fixQuotes (artCategory ) & "', " &_
" '" & fixQuotes (artBriefDesc ) & "', " &_
" '" & fixQuotes (artPrice ) & "', " &_
" '" & fixQuotes (artPicFull ) & "', " &_
" '" & fixQuotes (artHood ) & "', " &_
" '" & fixQuotes (artFace ) & "', " &_
" '" & fixQuotes (artCaseDesc ) & "', " &_
" '" & fixQuotes (artDialDesc ) & "', " &_
" '" & fixQuotes (artMovementDesc ) & "', " &_
" '" & fixQuotes (artMakerDesc ) & "', " &_
" '" & fixQuotes (artDateDesc ) & "', " &_
" '" & fixQuotes (artHeightDesc ) & "', " &_
" " & fixQuotes (artMoonDisplay ) & ", " &_
" '" & fixQuotes (artStatus ) & "', " &_
" " & fixQuotes (artDisplay ) & ", )"

and now my error is this:

Microsoft JET Database Engine error '80040e14'

Syntax error in INSERT INTO statement

for the same area.

Cheers

Lee
 
Are you sure there are values for your numeric values? If those are blank for any reason then it will error out. You may be better off here by doing a response.write of your SQL statement and then debugging in your database directly.

------------------------------------------------------------------------------------------------------------------------
"Men occasionally stumble over the truth, but most of them pick themselves up and hurry off as if nothing ever happened."
- Winston Churchill
 
Hi Chopstik,

Ye there should def be numerical values, as the values in the admin page is 0 & 1.

Can you give me an idea of what you mean, much appreciate that if you could.

lee

 
When I say that you should response.write out your code to see what your error may be, what I mean is this:
Code:
    if addProduct <> "" then
    strsqlM = "INSERT INTO eventDisplay " &_
        "( art_Title, art_Category, art_BDescription, art_Price, art_ThumbFull, art_ThumbHood, art_ThumbFace, case_Text, dial_Text, movement_Text, maker_Text, date_Text, height_Text, art_Status, art_Display, art_MoonDisplay  ) VALUES (" &_    
        " '" & fixQuotes (artTitle ) & "', " &_
            " '" & fixQuotes (artCategory ) & "', " &_
                " '" & fixQuotes (artBriefDesc ) & "', " &_
                    " '" & fixQuotes (artPrice ) & "', " &_
                        " '" & fixQuotes (artPicFull ) & "', " &_
                            " '" & fixQuotes (artHood ) & "', " &_
                                " '" & fixQuotes (artFace ) & "', " &_
                                    " '" & fixQuotes (artCaseDesc ) & "', " &_
                                        " '" & fixQuotes (artDialDesc ) & "', " &_
                                            " '" & fixQuotes (artMovementDesc ) & "', " &_
                                                " '" & fixQuotes (artMakerDesc ) & "', " &_
                                                    " '" & fixQuotes (artDateDesc ) & "', " &_
                                                        " '" & fixQuotes (artHeightDesc ) & "', " &_
                                                            " " & fixQuotes (artMoonDisplay ) & ", " &_
                                                                " '" & fixQuotes (artStatus ) & "', " &_
                                                                    " " & fixQuotes (artDisplay ) & ", )" 
response.write strsqlM
response.end
This will write out your entire SQL statement that you can then take into Access or SQL Server (or whatever your db is) and then test to see where the error is. Does this make sense?

------------------------------------------------------------------------------------------------------------------------
"Men occasionally stumble over the truth, but most of them pick themselves up and hurry off as if nothing ever happened."
- Winston Churchill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top