using variable in script

J

Jeff

using access db and asp

i have a variable from a form
sRound = request.form("round") and for now let us say this value is 3

now i want to include that 3 in sql, but it is part of a field name which
is round3_report

cm.CommandText ="UPDATE rounds SET round" & sRound & "_report = '" & var5 &
"' WHERE Name ='" & sName & "' AND meeting = " & var4 & ""
cm.execute

this isn't working. i keep getting parameter error. i know there is a way to
join a word with a variable in order to make a field name in asp/sql, but I
don't remember how

can you help?
thanks
 
R

Ray Costanzo [MVP]

Response.Write out the SQL query to see what's being passed.

Ray at work
 
B

Bob Barrows [MVP]

Jeff said:
using access db and asp

i have a variable from a form
sRound = request.form("round") and for now let us say this value is 3

now i want to include that 3 in sql, but it is part of a field name
which is round3_report

cm.CommandText ="UPDATE rounds SET round" & sRound & "_report = '" &
var5 & "' WHERE Name ='" & sName & "' AND meeting = " & var4 & ""
cm.execute

this isn't working. i keep getting parameter error. i know there is a
way to join a word with a variable in order to make a field name in
asp/sql, but I don't remember how

can you help?
thanks
Instead of dynamic sql, use parameters:
http://groups-beta.google.com/group/microsoft.public.inetserver.asp.db/msg/72e36562fee7804e


Actually, I prefer using saved parameter queries:
http://groups.google.com/groups?hl=...=1&[email protected]

http://groups.google.com/groups?hl=...=1&[email protected]

http://www.google.com/[email protected]&oe=UTF-8&output=gplain

http://www.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&[email protected]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,145
Messages
2,570,826
Members
47,372
Latest member
LucretiaFo

Latest Threads

Top