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 18th, 2007, 08:52 AM
Authorized User
 
Join Date: Jun 2006
Posts: 60
Thanks: 1
Thanked 0 Times in 0 Posts
Default Update Query Help

I'm trying to update a field in my database (SQL) using the following query:

Code:
set Conn=Server.CreateObject("ADODB.Connection")
set rsUpdate = server.CreateObject("ADODB.Recordset")
Conn.open "Driver={SQL Server}; Server=myserver;Database=StanEval;UID=xx;PWD=xx;"

set rsUpdate = conn.Execute "Update usertbl SET written_exam = '" & _ Trim(Request.Form("written_exam")) & "'  " & _
" where user_ID = " & Request.Form("user_ID")
But I'm getting the following error:

Microsoft VBScript compilation error '800a0401'

Expected end of statement

/staneval/update.asp, line 74

set rsUpdate = conn.Execute "Update usertbl SET written_exam = '" & _ Trim(Request.Form("written_exam")) & "' " & _



 
Old June 18th, 2007, 06:58 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

You dont need the underscore before you trim. Try:

set rsUpdate = conn.Execute "UPDATE usertbl SET written_exam = '" & Trim(Request.Form("written_exam")) & "' WHERE user_ID = " & Request.Form("user_ID") & ";"

Note the trailing semi colon, this is always a good idea

Wind is your friend
Matt
 
Old June 19th, 2007, 06:31 AM
Authorized User
 
Join Date: Jun 2006
Posts: 60
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Still getting the following error:

Microsoft VBScript compilation error '800a0401'

Expected end of statement

/staneval/update.asp, line 76

set rsUpdate = conn.Execute "UPDATE usertbl SET written_exam = '" & Trim(Request.Form("written_exam")) & "' WHERE user_ID = " & Request.Form("user_ID") & ";"
----------------------------^




 
Old March 10th, 2008, 03:06 PM
Authorized User
 
Join Date: Jun 2006
Posts: 60
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Yes, it's been a while, but I'm still interested in some help on this.

 
Old March 14th, 2008, 04:12 PM
Authorized User
 
Join Date: Jun 2006
Posts: 60
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Bump.

 
Old March 14th, 2008, 07:10 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Do this, and post the resulting string

Dim sql
sql = "Update usertbl SET written_exam = '" & Trim(Request.Form("written_exam")) & "' " _
& " where user_ID = " & Request.Form("user_ID")

Response.Write sql

hth.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor / Author :.
Wrox Books 24 x 7
================================================== =========
 
Old March 15th, 2008, 01:36 AM
Friend of Wrox
 
Join Date: May 2006
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Wow. 9 months since the original post, and still no answer. I don't think I have that much patience. Anyway...

Okay, tell me if I am wrong, guys. But don't you need parenthesis for a function call returning a value used in an expresion? Such as:

Code:
set rsUpdate = conn.Execute("UPDATE usertbl SET written_exam = '" & Trim(Request.Form("written_exam")) & "' WHERE user_ID = " & Request.Form("user_ID") & ";")
Or something like that. Of course, there could be a few other problems, but that is a start.


Woody Z
http://www.learntoprogramnow.com
How to use a forum to help solve problems
My blog... please visit
 
Old March 18th, 2008, 08:47 AM
Authorized User
 
Join Date: Jun 2006
Posts: 60
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by dparsons
 Do this, and post the resulting string

Dim sql
sql = "Update usertbl SET written_exam = '" & Trim(Request.Form("written_exam")) & "' " _
& " where user_ID = " & Request.Form("user_ID")

Response.Write sql

hth.
Here's the output:

Update usertbl SET written_exam = '' where user_ID =

 
Old March 18th, 2008, 08:49 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

This is an invalid SQL Statement: Update usertbl SET written_exam = '' where user_ID = because your where clause is empty. You need to have a value for userID.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor / Author :.
Wrox Books 24 x 7
================================================== =========





Similar Threads
Thread Thread Starter Forum Replies Last Post
Update Query rsm42 ASP.NET 1.0 and 1.1 Basics 0 April 9th, 2007 09:32 AM
I solved insert query.now see this Update Query. amit_mande@yahoo.com VB.NET 2002/2003 Basics 2 September 21st, 2006 12:48 AM
Update query trab Access 1 May 11th, 2006 03:58 PM
Please Help me about UPDATE query huyremy VB Databases Basics 8 September 29th, 2004 03:45 AM
Update query edcaru Access 3 June 14th, 2004 03:04 AM





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