 |
| Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0 |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

June 26th, 2005, 09:08 AM
|
|
Registered User
|
|
Join Date: Apr 2005
Posts: 352
Thanks: 14
Thanked 0 Times in 0 Posts
|
|
Problem in Updation.
Hi,
I m writing an update query, which gives error, Pls have a look @,
The error is :
Error Type:
Microsoft JET Database Engine (0x80040E14)
Syntax error (missing operator) in query expression ''P111' and ACTID = 7 and WTID = 5 and TeamID = 6 and Time_Hr = 3 and Time_mi = and workDate = #26-6-2005# and Comments = '''.
------------------
The code is :
------------------
set objRSPTS = objConn.execute("update timesheet set ProjID = '" & Request.Form("ProList1") & "' and ACTID = " & Request.Form("ActList1") & " and WTID = " & Request.Form("WTList1") & " and TeamID = " & Request.Form("TeamList1") & " and Time_Hr = " & Request.Form("Hours1") & " and Time_mi = " & Request.Form("Minute1") & " and workDate = #" & Request.Form("date1") & "# and Comments = '" & Request.Form("comments1") & "' where empid = " & session("empid") & " and tsid = 1")
------------------
As we can see it dosen't get any character from "where " clause.
Thanks in Advance.:)
|
|

June 26th, 2005, 06:15 PM
|
|
Friend of Wrox
|
|
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
|
|
What data type is the ProjID field? if it is an integer you should remove the single quotes. '" "' becomes " "
FYI:
1..All the and's between update fields should be replaced with commers.
2..You should finish sql statements with semi colons.
3..It is good practice to run trim functions around posted form values. Also a function to replace certain characters like single quotes etc. An example function would be:
Function StoreText(theText)
StoreText = ""
on error resume next
StoreText = CStr(theText)
if (len(StoreText) > 0) Then
StoreText = Replace(StoreText, """", """, 1, -1, 1)
StoreText = Replace(StoreText, "'", "''", 1, -1, 1)
end if
End Function
To use this function:
Comments = '" & trim(storeText(Request.Form("comments1"))) & "', WHERE...
Your sql should be:
set objRSPTS = objConn.execute("UPDATE timesheet SET ProjID = '" & Request.Form("ProList1") & "', ACTID = " & Request.Form("ActList1") & ", WTID = " & Request.Form("WTList1") & ", TeamID = " & Request.Form("TeamList1") & ", Time_Hr = " & Request.Form("Hours1") & ", Time_mi = " & Request.Form("Minute1") & ", workDate = #" & Request.Form("date1") & "#, Comments = '" & Request.Form("comments1") & "', WHERE empid = " & session("empid") & " AND tsid = 1;")
;;;As we can see it dosen't get any character from "where " clause
print your query in the browser and post it at run time.
Wind is your friend
Matt
|
|

June 27th, 2005, 12:25 AM
|
|
Registered User
|
|
Join Date: Apr 2005
Posts: 352
Thanks: 14
Thanked 0 Times in 0 Posts
|
|
Thankx...ProjID is character.
Further, in where clause, I m getting tsid from previous form's query string,
so when i tried,
--
where empid = " & session("empid") & " and tsid = " & request.querystring("tsid")
--
it returns that data type mismatch , even not working with CInt(), CLng, can u elobarate on converting query string value to numeric long type??
Again Thanks in Advance.
|
|

June 27th, 2005, 12:40 AM
|
|
Friend of Wrox
|
|
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
|
|
You shouldnt have to convert it, you can compare it to its self. your problem is elsewhere. Print your query in the browser and post it. You should get into the habbit of pasting queries into access to check them, change:
set objRSPTS = objConn.execute("UPDATE...
to
objRSPTS = ("UPDATE...
response.write objRSPTS & "=post this string<br>"
Wind is your friend
Matt
|
|

June 27th, 2005, 07:05 AM
|
|
Registered User
|
|
Join Date: Apr 2005
Posts: 352
Thanks: 14
Thanked 0 Times in 0 Posts
|
|
I can't figure it out..but when I store value of tsid in session variable, it works very fine. This has happened 2nd time, I think getting value from querystring has some limitation.
Anyway thanks for help.
|
|

June 27th, 2005, 07:17 PM
|
|
Friend of Wrox
|
|
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
|
|
;;;I can't figure it out
What cant you figure out, how to print the query to the browser? I difficult to help without seeing it. Help others help you...
Wind is your friend
Matt
|
|
 |