There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
access audio avg avg 8 bios blue screen boot bsod computer connection cpu crash css dell desktop dma driver drivers dvd email error excel explorer firefox firefox 3 freeze gimp graphics hard drive hardware hijackthis hjt install internet internet explorer itunes keyboard laptop macro malware monitor motherboard network networking outlook outlook 2003 outlook 2007 outlook express pio problem problems router seo server slow sound sp3 spyware trojan usb video virtumonde virus vista vundo windows windows vista windows xp winxp wireless
Software Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Software & Hardware > Software Development >
sql help


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

 
Thread Tools
macataq's Avatar
Senior Member with 181 posts.
 
Join Date: Aug 2002
Location: canada
24-Dec-2006, 02:43 AM #1
sql help
hello
having problems with the following SQL statement


sql = "UPDATE totals(WK 16) VALUES(" & scorestr &")"_
& " where Username = " &Session("FootballPoolUsername")

Set rs = DbConn.Execute(sql)
displays;

Error Type:
Microsoft JET Database Engine (0x80040E14)
Syntax error in UPDATE statement.
/results.asp, line 235

but when i do a
response.write it displays
UPDATE totals(WK 16) VALUES(13) where Username = MyName
wk 16 is the column i want the value to go into,
13 is the correct value
Myname is also correct

the problem is the error message and nothing is written to the DB.

could anyone point out my mistake?

Thank you

Michael
__________________
Eh?
Chicon's Avatar
Computer Specs
Distinguished Member with 6,598 posts.
 
Join Date: Jul 2004
Location: 50° 34' 07.13" N - 04° 10' 23.
Experience: Second socks retriever
24-Dec-2006, 02:59 AM #2
Hi macataq,

The underscore character in the following statement is it correct ?

sql = "UPDATE totals(WK 16) VALUES(" & scorestr &")"_
& " where Username = " &Session("FootballPoolUsername")
macataq's Avatar
Senior Member with 181 posts.
 
Join Date: Aug 2002
Location: canada
24-Dec-2006, 03:06 AM #3
Chicon
thanks for the reply
i believe that it is required when the query continues on more that one line.

Mac
Chicon's Avatar
Computer Specs
Distinguished Member with 6,598 posts.
 
Join Date: Jul 2004
Location: 50° 34' 07.13" N - 04° 10' 23.
Experience: Second socks retriever
24-Dec-2006, 04:16 AM #4
In SQL, the correct syntax of a basic UPDATE statement is in the following structure :

Code:
 UPDATE tableName SET columnName = ...
WHERE condition expression
It is applicable for Oracle, DB2, MySQL and Access. The multi-lines representation is not mandatory, it is only aimed for the readability.

Link : http://msdn2.microsoft.com/en-us/lib...ffice.10).aspx

Therefore, your SQL statement should be :

sql = "UPDATE totals SET WK 16 = " & scorestr & " WHERE Username = " & Session("FootballPoolUsername")

Remark : the column name is not a single word, is it allowed in Access ?
-------- I know it is not allowed in Oracle, MySQL and DB2.
macataq's Avatar
Senior Member with 181 posts.
 
Join Date: Aug 2002
Location: canada
24-Dec-2006, 11:16 AM #5
hi Chicon
i have changed the column names in my DB to WK_1.....WK_17
still get a syntax error.
thanks
Mac
Chicon's Avatar
Computer Specs
Distinguished Member with 6,598 posts.
 
Join Date: Jul 2004
Location: 50° 34' 07.13" N - 04° 10' 23.
Experience: Second socks retriever
24-Dec-2006, 11:37 AM #6
Sorry, I didn't know single quotes were mandatory for Microsoft Jet SQL.

The values must be enclosed with single quotes this way :

sql = "UPDATE totals SET WK_16 = '" & scorestr & "' WHERE Username = '" & Session("FootballPoolUsername") & "'"
macataq's Avatar
Senior Member with 181 posts.
 
Join Date: Aug 2002
Location: canada
26-Dec-2006, 10:52 AM #7
hi Chicon
thanks for the reply
this statement appears to work(no error)
but nothing is being sent to the Access DB
i do have the correct permissions in place
and the data type is correct.
any ideas on what else could be causing this

Thanx

Mac
Chicon's Avatar
Computer Specs
Distinguished Member with 6,598 posts.
 
Join Date: Jul 2004
Location: 50° 34' 07.13" N - 04° 10' 23.
Experience: Second socks retriever
26-Dec-2006, 02:54 PM #8
It seems your database is not automatically refreshed after execution of the SQL update. It needs the Oracle equivalent of a commit instruction.
You have probably to implement a transaction in VB with a begin, a commit and eventually a rollback.
macataq's Avatar
Senior Member with 181 posts.
 
Join Date: Aug 2002
Location: canada
01-Jan-2007, 01:35 AM #9
hello
i have looked up on ggogle everything i can follow
still cant this to work, i dont understand why the Response.write is showing the data i want to send to the db on the presnet page , but will not write it to the db?

Mac
Chicon's Avatar
Computer Specs
Distinguished Member with 6,598 posts.
 
Join Date: Jul 2004
Location: 50° 34' 07.13" N - 04° 10' 23.
Experience: Second socks retriever
01-Jan-2007, 07:28 AM #10
I have found out an example on this page from a French forum.
The example shows the way to connect and disconnect from a DB and the way to perform a SQL request (SELECT, INSERT, DELETE, UPDATE) in a VB script.
macataq's Avatar
Senior Member with 181 posts.
 
Join Date: Aug 2002
Location: canada
10-Jan-2007, 10:27 PM #11
hi again
okay i have gotten the sql to write the value to the db.
i need to be able to write it to the correct week. i have
so far only been able to write it to the table by specifying
the column name in the Set statement, e.g SET WEEK_12 = & SCORESTR &.
i would like send it to the current week, but i dont know how to go about it .
any ideas?
thank you for any help

Macataq
__________________
Eh?
Chicon's Avatar
Computer Specs
Distinguished Member with 6,598 posts.
 
Join Date: Jul 2004
Location: 50° 34' 07.13" N - 04° 10' 23.
Experience: Second socks retriever
11-Jan-2007, 02:27 PM #12
There's a formula to compute the week number on this page :

http://forums.microsoft.com/MSDN/Sho...02193&SiteID=1
macataq's Avatar
Senior Member with 181 posts.
 
Join Date: Aug 2002
Location: canada
11-Jan-2007, 06:50 PM #13
i am not trying to determine the week of the year or the week of the month.
i am trying to determine the week of the season (17 week nfl season)
thats how my db is laid out e.g. week_1, week_2, week_3 etc..etc
hope that clarifies what i am trying to accomplish

thanx


Mac
__________________
Eh?
AGCurry's Avatar
Senior Member with 431 posts.
 
Join Date: Jun 2005
Location: Kansas City area
Experience: advanced but learning
11-Jan-2007, 08:39 PM #14
Quote:
Originally Posted by macataq
i am not trying to determine the week of the year or the week of the month.
i am trying to determine the week of the season (17 week nfl season)
thats how my db is laid out e.g. week_1, week_2, week_3 etc..etc
hope that clarifies what i am trying to accomplish
An excellent example of why normalization is good and repeating groups are bad.
macataq's Avatar
Senior Member with 181 posts.
 
Join Date: Aug 2002
Location: canada
11-Jan-2007, 10:21 PM #15
ACCurry;

thanks for your 2 cents..... worth every penny!

Mac
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are Off
Refbacks are Off

You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 07:00 PM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.