Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old December 27th, 2006, 08:05 PM
pmarisole
Guest
 
Posts: n/a
Default Help with Updating Multiple Records via Looping

This is the first page......

<select size="1" name="Q1_<%=i%>" onChange="calc(<%=i%>)">
<option selected value="<% =rsScores("Q1")
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
</select>
<%
rsScores.movenext
loop
%>
<input type="hidden" name="x" value="<%=i%>">

This is the page that it posts to......
Dim strID, QQ1
Set Conn5S = Server.CreateObject("ADODB.Connection")
Conn5S.Open "Provider=sqloledb;Data
Source=ebs-sqlc1-vs3.edn.runi.com\SSS;UID=casuser;PWD=hppccas;DATAB ASE=skills"
count = Request.Form("x") - 1
for i = 0 to (count)
strID = Request.form("Emp & " i " &"'")
QQ1= Request.form("Q1 & " i " &"'")
sSQL = "UPDATE ECuryear SET Q1= '" & QQ1 & "' where (empid ='" & strID
& "')"
Conn5S.Execute(sSQL)
NEXT

When I execute the web page with a response.write on the sequel
statement, this is what it returns. Does anyone see what I am doing
wrong?

UPDATE ECuryear SET Q1= '' where (empid ='')

  #2  
Old December 27th, 2006, 09:15 PM
Bob Barrows [MVP]
Guest
 
Posts: n/a
Default Re: Help with Updating Multiple Records via Looping

jbarnes5@midsouth.rr.com wrote:
Quote:
This is the first page......
>
<select size="1" name="Q1_<%=i%>" onChange="calc(<%=i%>)">
<option selected value="<% =rsScores("Q1")
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
</select>
<%
rsScores.movenext
loop
%>
<input type="hidden" name="x" value="<%=i%>">
>
>
This is the page that it posts to......
Dim strID, QQ1
Set Conn5S = Server.CreateObject("ADODB.Connection")
Conn5S.Open "Provider=sqloledb;Data
Source=ebs-sqlc1-vs3.edn.runi.com\SSS;UID=casuser;PWD=hppccas;DATAB ASE=skil*ls"
>
count = Request.Form("x") - 1
for i = 0 to (count)
strID = Request.form("Emp & " i " &"'")
QQ1= Request.form("Q1 & " i " &"'")
sSQL = "UPDATE ECuryear SET Q1= '" & QQ1 & "' where (empid ='" & strID
& "')"
Conn5S.Execute(sSQL)
NEXT
>
>
When I execute the web page with a response.write on the sequel
statement, this is what it returns. Does anyone see what I am doing
wrong?
>
>
UPDATE ECuryear SET Q1= '' where (empid ='')

The only way to find out will be to look at the result of posting your form
a page containing to this:

<%
Dim strID, QQ1
count = Request.Form("x") - 1
Response.Write "count contains '" & count & "'<BR>"
for i = 0 to (count)
Response.Write "i contains '" & i & "'<BR>"
strID = Request.form("Emp & " i " &"'")
Response.Write "strID contains '" & strID & "'<BR>"
QQ1= Request.form("Q1 & " i " &"'")
Response.Write "QQ1 contains '" & QQ1 & "'<BR>"
sSQL = "UPDATE ECuryear SET Q1= '" & QQ1 & "' where (empid ='" & strID
& "')"
Response.Write "sSQL contains '" & sSQL & "'<BR>"
NEXT
%>


--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"



  #3  
Old December 27th, 2006, 09:15 PM
Bob Lehmann
Guest
 
Posts: n/a
Default Re: Help with Updating Multiple Records via Looping

I'm guessing that what you are trying to do is to cat your counter with the
form element value. The code you supplied is mess, so it's hard to tell.

But, anyhoooo.......

strID = Request.form("Emp" & i )
QQ1= Request.form("Q1" & i )

Also, I don't see that you have an element named "Emp"

Bob Lehmann

"pmarisole" <jbarnes5@midsouth.rr.comwrote in message
news:1167249276.204142.71530@42g2000cwt.googlegrou ps.com...
Quote:
This is the first page......
>
<select size="1" name="Q1_<%=i%>" onChange="calc(<%=i%>)">
<option selected value="<% =rsScores("Q1")
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
</select>
<%
rsScores.movenext
loop
%>
<input type="hidden" name="x" value="<%=i%>">
>
This is the page that it posts to......
Dim strID, QQ1
Set Conn5S = Server.CreateObject("ADODB.Connection")
Conn5S.Open "Provider=sqloledb;Data
>
Source=ebs-sqlc1-vs3.edn.runi.com\SSS;UID=casuser;PWD=hppccas;DATAB ASE=skill
s"
Quote:
count = Request.Form("x") - 1
for i = 0 to (count)
strID = Request.form("Emp & " i " &"'")
QQ1= Request.form("Q1 & " i " &"'")
sSQL = "UPDATE ECuryear SET Q1= '" & QQ1 & "' where (empid ='" & strID
& "')"
Conn5S.Execute(sSQL)
NEXT
>
When I execute the web page with a response.write on the sequel
statement, this is what it returns. Does anyone see what I am doing
wrong?
>
UPDATE ECuryear SET Q1= '' where (empid ='')
>

  #4  
Old December 27th, 2006, 09:35 PM
Bob Barrows [MVP]
Guest
 
Posts: n/a
Default Re: Help with Updating Multiple Records via Looping

Bob Barrows [MVP] wrote:
Quote:
>
<%
Dim strID, QQ1
count = Request.Form("x") - 1
Response.Write "count contains '" & count & "'<BR>"
for i = 0 to (count)
Response.Write "i contains '" & i & "'<BR>"
strID = Request.form("Emp & " i " &"'")
Response.Write "strID contains '" & strID & "'<BR>"
QQ1= Request.form("Q1 & " i " &"'")
Response.Write "QQ1 contains '" & QQ1 & "'<BR>"
sSQL = "UPDATE ECuryear SET Q1= '" & QQ1 & "' where (empid ='" & strID
& "')"
Response.Write "sSQL contains '" & sSQL & "'<BR>"
NEXT
%>
actually, it should look like this:

<%
Dim key, strID, QQ1
For Each key in Request.Form
Response.Write "Request.Form(key) contains '" & _
Request.Form(key) & "'<BR>"
Next
count = Request.Form("x") - 1
Response.Write "count contains '" & count & "'<BR>"
for i = 0 to (count)
Response.Write "i contains '" & i & "'<BR>"
strID = Request.form("Emp & " i " &"'")
Response.Write "strID contains '" & strID & "'<BR>"
QQ1= Request.form("Q1 & " i " &"'")
Response.Write "QQ1 contains '" & QQ1 & "'<BR>"
sSQL = "UPDATE ECuryear SET Q1= '" & QQ1 & "' where (empid ='" & strID
& "')"
Response.Write "sSQL contains '" & sSQL & "'<BR>"
NEXT
%>

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


  #5  
Old December 27th, 2006, 10:25 PM
pmarisole
Guest
 
Posts: n/a
Default Re: Help with Updating Multiple Records via Looping


Bob Barrows [MVP] wrote:
Quote:
Bob Barrows [MVP] wrote:
Quote:

<%
Dim strID, QQ1
count = Request.Form("x") - 1
Response.Write "count contains '" & count & "'<BR>"
for i = 0 to (count)
Response.Write "i contains '" & i & "'<BR>"
strID = Request.form("Emp & " i " &"'")
Response.Write "strID contains '" & strID & "'<BR>"
QQ1= Request.form("Q1 & " i " &"'")
Response.Write "QQ1 contains '" & QQ1 & "'<BR>"
sSQL = "UPDATE ECuryear SET Q1= '" & QQ1 & "' where (empid ='" & strID
& "')"
Response.Write "sSQL contains '" & sSQL & "'<BR>"
NEXT
%>
>
actually, it should look like this:
>
<%
Dim key, strID, QQ1
For Each key in Request.Form
Response.Write "Request.Form(key) contains '" & _
Request.Form(key) & "'<BR>"
Next
count = Request.Form("x") - 1
Response.Write "count contains '" & count & "'<BR>"
for i = 0 to (count)
Response.Write "i contains '" & i & "'<BR>"
strID = Request.form("Emp & " i " &"'")
Response.Write "strID contains '" & strID & "'<BR>"
QQ1= Request.form("Q1 & " i " &"'")
Response.Write "QQ1 contains '" & QQ1 & "'<BR>"
sSQL = "UPDATE ECuryear SET Q1= '" & QQ1 & "' where (empid ='" & strID
& "')"
Response.Write "sSQL contains '" & sSQL & "'<BR>"
NEXT
%>
>
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"

Thanks for the response but when I used the code above this is the
response I got.

Microsoft VBScript compilation error '800a03ee'

Expected ')'

/EAP/QSUpdated.asp, line 21

strID = Request.form("Emp & " i " &"'")
------------------------------^

  #6  
Old December 27th, 2006, 11:15 PM
Bob Barrows [MVP]
Guest
 
Posts: n/a
Default Re: Help with Updating Multiple Records via Looping

pmarisole wrote:
Quote:
Thanks for the response but when I used the code above this is the
response I got.
>
Microsoft VBScript compilation error '800a03ee'
>
Expected ')'
>
/EAP/QSUpdated.asp, line 21
>
strID = Request.form("Emp & " i " &"'")
------------------------------^
Well, I'm surprised you didn't get this error in the first place because I
essentially copied your code. The line should look like this, of course:

strID = Request.form("Emp" & i )

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


  #7  
Old December 27th, 2006, 11:15 PM
Bob Barrows [MVP]
Guest
 
Posts: n/a
Default Re: Help with Updating Multiple Records via Looping

pmarisole wrote:
Quote:
Thanks for the response but when I used the code above this is the
response I got.
>
Microsoft VBScript compilation error '800a03ee'
>
Expected ')'
>
/EAP/QSUpdated.asp, line 21
>
strID = Request.form("Emp & " i " &"'")
------------------------------^
And my suggested code would be more helpful if it looked like this:
For Each key in Request.Form
Response.Write "Request.Form(""" & key & """) contains '" & _
Request.Form(key) & "'<BR>"
Next

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


  #8  
Old December 28th, 2006, 04:25 PM
pmarisole
Guest
 
Posts: n/a
Default Re: Help with Updating Multiple Records via Looping


Bob Barrows [MVP] wrote:
Quote:
pmarisole wrote:
>
Quote:
Thanks for the response but when I used the code above this is the
response I got.

Microsoft VBScript compilation error '800a03ee'

Expected ')'

/EAP/QSUpdated.asp, line 21

strID = Request.form("Emp & " i " &"'")
------------------------------^
>
And my suggested code would be more helpful if it looked like this:
For Each key in Request.Form
Response.Write "Request.Form(""" & key & """) contains '" & _
Request.Form(key) & "'<BR>"
Next
>
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
I added your code as follows:
<%
Dim
strID,QQ1,QQ2,QQ3,QQ4,QQ5,QQ6,QQ7,QQ8,QQ9,QS,FYVar ,count,i,sSQL,Conn5S,key
'************************************************* ****************************
Set Conn5S = Server.CreateObject("ADODB.Connection")
Conn5S.Open "Provider=sqloledb;Data
Source=ebs-sqlc1-vs3.edn.runi.com\SSS;UID=casuser;PWD=hppccas;DATAB ASE=skills"

For Each key in Request.Form
Response.Write "Request.Form(""" & key & """) contains '" & _
Request.Form(key) & "'<BR>"
Next
count = Request.Form("x") - 1
Response.Write "count contains '" & count & "'<BR>"
for i = 0 to (count)
Response.Write "i contains '" & i & "'<BR>"
strID = Request.form("Emp" & i)
Response.Write "strID contains '" & strID & "'<BR>"
QQ1 = Request.form("Q1" & i)
Response.Write "QQ1 contains '" & QQ1 & "'<BR>"
QQ2 = Request.form("Q2" & i)
Response.Write "QQ2 contains '" & QQ2 & "'<BR>"
QQ3 = Request.form("Q3" & i)
Response.Write "QQ3 contains '" & QQ3 & "'<BR>"
QQ4 = Request.form("Q4" & i)
Response.Write "QQ4 contains '" & QQ4 & "'<BR>"
QQ5 = Request.form("Q5" & i)
Response.Write "QQ5 contains '" & QQ5 & "'<BR>"
QQ6 = Request.form("Q6" & i)
Response.Write "QQ6 contains '" & QQ6 & "'<BR>"
QQ7 = Request.form("Q7" & i)
Response.Write "QQ7 contains '" & QQ7 & "'<BR>"
QQ8 = Request.form("Q8" & i)
Response.Write "QQ8 contains '" & QQ8 & "'<BR>"
QQ9 = Request.form("Q9" & i)
Response.Write "QQ9 contains '" & QQ9 & "'<BR>"
sSQL = "UPDATE ECuryear SET Q1= '" & QQ1 & "',Q2= '" & QQ2 & "',Q3= '"
& QQ3 & "',Q4= '" & QQ4 & "',Q5= '" & QQ5 & "',Q6= '" & QQ6 & "',Q7= '"
& QQ7 & "',Q8= '" & QQ8 & "',Q9= '" & QQ9 & "', where (empid ='" &
strID & "')"
Response.Write "sSQL contains '" & sSQL & "'<BR>"
on error resume next
Conn5S.Execute(sSQL)
NEXT
%>

THIS IS THE REPONSE I GET....... It shows the value of the fields when
I loop through
the key but when I call the field QQ1= Request.form("Q1" & i), I
don't get the value to add to the database. What could be wrong?

Request.Form("Emp_1") contains '223851'
Request.Form("Q1_1") contains '3'
Request.Form("Q2_1") contains '3'
Request.Form("Q3_1") contains '3'
Request.Form("Q4_1") contains '3'
Request.Form("Q5_1") contains '3'
Request.Form("Q6_1") contains '3'
Request.Form("Q7_1") contains '3'
Request.Form("Q8_1") contains '3'
Request.Form("Q9_1") contains '3'
Request.Form("fy06_1") contains '8.33'
Request.Form("fy07_1") contains '3'
Request.Form("fy08_1") contains '-5.33'

Request.Form("Emp_2") contains '24224'
Request.Form("Q1_2") contains '8'
Request.Form("Q2_2") contains '8'
Request.Form("Q3_2") contains '8'
Request.Form("Q4_2") contains '8'
Request.Form("Q5_2") contains '8'
Request.Form("Q6_2") contains '8'
Request.Form("Q7_2") contains '8'
Request.Form("Q8_2") contains '8'
Request.Form("Q9_2") contains '8'
Request.Form("fy06_2") contains '7.25'
Request.Form("fy07_2") contains '8'
Request.Form("fy08_2") contains '0.75'
Request.Form("x") contains '2'
i contains '0'
strID contains ''
QQ1 contains ''
QQ2 contains ''
QQ3 contains ''
QQ4 contains ''
QQ5 contains ''
QQ6 contains ''
QQ7 contains ''
QQ8 contains ''
QQ9 contains ''
sSQL contains 'UPDATE ECuryear SET Q1= '',Q2= '',Q3= '',Q4= '',Q5=
'',Q6= '',Q7= '',Q8= '',Q9= '', where (empid ='')'
i contains '1'
strID contains ''
QQ1 contains ''
QQ2 contains ''
QQ3 contains ''
QQ4 contains ''
QQ5 contains ''
QQ6 contains ''
QQ7 contains ''
QQ8 contains ''
QQ9 contains ''
sSQL contains 'UPDATE ECuryear SET Q1= '',Q2= '',Q3= '',Q4= '',Q5=
'',Q6= '',Q7= '',Q8= '',Q9= '', where (empid ='')'

Thanks for your help

  #9  
Old December 28th, 2006, 04:35 PM
Bob Barrows [MVP]
Guest
 
Posts: n/a
Default Re: Help with Updating Multiple Records via Looping

pmarisole wrote:
Quote:
THIS IS THE REPONSE I GET....... It shows the value of the fields
when I loop through
the key but when I call the field QQ1= Request.form("Q1" & i), I
don't get the value to add to the database. What could be wrong?
>
Request.Form("Emp_1") contains '223851'
Request.Form("Q1_1") contains '3'
Well, what do you get when you do this when i contains 1:

Response.Write "'" & "Q1" & i & "'"

Run it and see. I'll bet you don't see 'Q1_1' do you? You probably see
'Q11'
The solution is to change
QQ1= Request.form("Q1" & i)
to
QQ1= Request.form("Q1_" & i)
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.


  #10  
Old January 4th, 2007, 05:35 PM
pmarisole
Guest
 
Posts: n/a
Default Re: Help with Updating Multiple Records via Looping


Bob Barrows [MVP] wrote:
Quote:
pmarisole wrote:
Quote:
THIS IS THE REPONSE I GET....... It shows the value of the fields
when I loop through
the key but when I call the field QQ1= Request.form("Q1" & i), I
don't get the value to add to the database. What could be wrong?

Request.Form("Emp_1") contains '223851'
Request.Form("Q1_1") contains '3'
>
Well, what do you get when you do this when i contains 1:
>
Response.Write "'" & "Q1" & i & "'"
>
Run it and see. I'll bet you don't see 'Q1_1' do you? You probably see
'Q11'
The solution is to change
QQ1= Request.form("Q1" & i)
to
QQ1= Request.form("Q1_" & i)
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Thanks so much, It works as you said.

  #11  
Old January 4th, 2007, 05:35 PM
pmarisole
Guest
 
Posts: n/a
Default Re: Help with Updating Multiple Records via Looping


Bob Barrows [MVP] wrote:
Quote:
pmarisole wrote:
Quote:
THIS IS THE REPONSE I GET....... It shows the value of the fields
when I loop through
the key but when I call the field QQ1= Request.form("Q1" & i), I
don't get the value to add to the database. What could be wrong?

Request.Form("Emp_1") contains '223851'
Request.Form("Q1_1") contains '3'
>
Well, what do you get when you do this when i contains 1:
>
Response.Write "'" & "Q1" & i & "'"
>
Run it and see. I'll bet you don't see 'Q1_1' do you? You probably see
'Q11'
The solution is to change
QQ1= Request.form("Q1" & i)
to
QQ1= Request.form("Q1_" & i)
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Thanks so much, It works as you said.

 

Bookmarks

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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles