Wrox Programmer Forums
|
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
 
Old June 26th, 2005, 09:08 AM
Registered User
 
Join Date: Apr 2005
Posts: 352
Thanks: 14
Thanked 0 Times in 0 Posts
Send a message via Yahoo to rupen
Default 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.:)


 
Old June 26th, 2005, 06:15 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

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
 
Old June 27th, 2005, 12:25 AM
Registered User
 
Join Date: Apr 2005
Posts: 352
Thanks: 14
Thanked 0 Times in 0 Posts
Send a message via Yahoo to rupen
Default

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.

 
Old June 27th, 2005, 12:40 AM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

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
 
Old June 27th, 2005, 07:05 AM
Registered User
 
Join Date: Apr 2005
Posts: 352
Thanks: 14
Thanked 0 Times in 0 Posts
Send a message via Yahoo to rupen
Default

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.

 
Old June 27th, 2005, 07:17 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

;;;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





Similar Threads
Thread Thread Starter Forum Replies Last Post
help in updation sanjeev jha Classic ASP Basics 0 November 12th, 2007 04:17 AM
updation prob.......... abhit_kumar MySQL 0 December 14th, 2004 08:06 AM
Problem in updation abhit_kumar JSP Basics 3 November 30th, 2004 09:47 AM
updation problem abhit_kumar Java Databases 0 November 25th, 2004 01:45 AM
updation problem abhit_kumar Pro JSP 0 November 25th, 2004 01:44 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.