Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access_asp thread: Syntax error (missing operator) in query expression


Message #1 by onrampid@c... on Sun, 9 Feb 2003 01:11:10
Here is another one. Killin me for 2 days... now just too blury eyed..

TIA,

IE info

Microsoft JET Database Engine (0x80040E14)
Syntax error (missing operator) in query expression 'NoteID ='.
/ncusetup/nsjnoncuupdate1.asp, line 19

POST Data:
rsDate=2%2F10%2F2003&textfield2=+This+is+a+test+of+the+

Code:

<%@LANGUAGE="VBSCRIPT"%>
<%If Request.Form("update").Count > 0 Then
Dim iCount, iCount2, iLoop, varTextStr, varTextPly, varTextCon, 
varTextMt1, varTextImp, varTextToolnotes, varTextImpGoals, varToolID, 
varLyrID, varTextDate, varNoteID
	'iCount is the number of records to be updated
	iCount = Request("tCnt")
	iCount2 = Request("tCnt2")

set UpdateCom = Server.CreateObject("ADODB.Command")
UpdateCom.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data 
Source=C:\F22\nCusetup\NSJnoncu.mdb;"

	If Request("rsNotes.rsDate") <> "" then UpdateCom__varTextDate = 
Request(.rsDate)
	If Request("rsNotes.NoteID") <> "" then UpdateCom__varNoteID = 
Request(.NoteID)
	If Len(Trim(Request("rsNotes.rsDate"))) = 0 then 
UpdateCom__varTextDate = Date

UpdateCom.CommandText = "Update Notes SET rsDate = '" + Replace
(UpdateCom__varTextDate, "'", "''") + "' WHERE NoteID = " + Replace
(UpdateCom__varNoteID, "'", "''") + ""
UpdateCom.CommandType = 1
UpdateCom.CommandTimeout = 0
UpdateCom.Prepared = true
UpdateCom.Execute()

etc......
Message #2 by "Ken Schaefer" <ken@a...> on Mon, 10 Feb 2003 10:42:27 +1100
a) www.adopenstatic.com/faq/80040e14.asp

b) If you still have problems, you need to
<%
Response.Write(UpdateCom.CommandText)
Response.End
%>
and post the result so we can see what you're sending to the database

c) Use & as a string concatenation operator, not +, as + is an overloaded
operator, and you may not get the results your expect

d) Do not set the active connection of an ADO object (other than a
connection object) to a connection string, as you will defeat connection
pooling. Always explicitly create and open a connection object and pass this
to the Command/Recordset object

e) I'm not sure what you're doing here:
Request(.rsDate)

There does not appear to be any "With" statement, and you are not naming the
collection you wish to use. I realise that you can get away with not naming
the collection (but I don't think it's good programming practise), but the
lack of a With statement means you have a variable called .rsDate which I
don't think it allowed. You should be getting a compiler error.

Cheers
Ken

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: <onrampid@c...>
Subject: [access_asp] Syntax error (missing operator) in query expression


: Here is another one. Killin me for 2 days... now just too blury eyed..
:
: TIA,
:
: IE info
:
: Microsoft JET Database Engine (0x80040E14)
: Syntax error (missing operator) in query expression 'NoteID ='.
: /ncusetup/nsjnoncuupdate1.asp, line 19
:
: POST Data:
: rsDate=2%2F10%2F2003&textfield2=+This+is+a+test+of+the+
:
: Code:
:
: <%@LANGUAGE="VBSCRIPT"%>
: <%If Request.Form("update").Count > 0 Then
: Dim iCount, iCount2, iLoop, varTextStr, varTextPly, varTextCon,
: varTextMt1, varTextImp, varTextToolnotes, varTextImpGoals, varToolID,
: varLyrID, varTextDate, varNoteID
: 'iCount is the number of records to be updated
: iCount = Request("tCnt")
: iCount2 = Request("tCnt2")
:
: set UpdateCom = Server.CreateObject("ADODB.Command")
: UpdateCom.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data
: Source=C:\F22\nCusetup\NSJnoncu.mdb;"
:
: If Request("rsNotes.rsDate") <> "" then UpdateCom__varTextDate 
: Request(.rsDate)
: If Request("rsNotes.NoteID") <> "" then UpdateCom__varNoteID 
: Request(.NoteID)
: If Len(Trim(Request("rsNotes.rsDate"))) = 0 then
: UpdateCom__varTextDate = Date
:
: UpdateCom.CommandText = "Update Notes SET rsDate = '" + Replace
: (UpdateCom__varTextDate, "'", "''") + "' WHERE NoteID = " + Replace
: (UpdateCom__varNoteID, "'", "''") + ""
: UpdateCom.CommandType = 1
: UpdateCom.CommandTimeout = 0
: UpdateCom.Prepared = true
: UpdateCom.Execute()
:
: etc......


  Return to Index