Hi all,
I am totally puzzled over this piece of code:
<%
Dim iCount
iCount = Request.Form("Count"
Dim strSize, strImgURL, strSQL
Dim Command1
set Command1 = Server.CreateObject("ADODB.Connection"
Command1.ConnectionString = Connection_String
Command1.Open
Dim iLoop
For iLoop = 0 to iCount
strSize = Request(iLoop & ".varSize"
strImgURL = Request(iLoop & ".ImgURL"
strSQL = "INSERT INTO Table (ProductID, [Size], ImgURL) VALUES ('"& varProductID &"', '"& strSize &"', '"& strImgURL &"')"
Command1.Execute strSQL
Next
Command1.Close
Set Command1 = Nothing
%>
Basically what this piece of code should do is to retrieve the necessary values and insert it into the database "iCount" number of times.
Now say the iCount variable is 3, then it should insert into the database 3 times, but instead it inserted into the database 6 times(if iCount is 4 then instead of inserting 4 times it inserted 8 times).
I did a Response.Write(""& iCount &""
to make sure the iCount variable is correct and yes it indeed is a 3... so the counter variable is correct but it is just not behaving...
But when I inserted the number directly--instead of
For iLoop = 0 to iCount I put
For iLoop = 0 to 3
then everything works fine... Please advice.
Thanks in advance!
JoJoH
I am totally puzzled over this piece of code:
<%
Dim iCount
iCount = Request.Form("Count"

Dim strSize, strImgURL, strSQL
Dim Command1
set Command1 = Server.CreateObject("ADODB.Connection"

Command1.ConnectionString = Connection_String
Command1.Open
Dim iLoop
For iLoop = 0 to iCount
strSize = Request(iLoop & ".varSize"

strImgURL = Request(iLoop & ".ImgURL"

strSQL = "INSERT INTO Table (ProductID, [Size], ImgURL) VALUES ('"& varProductID &"', '"& strSize &"', '"& strImgURL &"')"
Command1.Execute strSQL
Next
Command1.Close
Set Command1 = Nothing
%>
Basically what this piece of code should do is to retrieve the necessary values and insert it into the database "iCount" number of times.
Now say the iCount variable is 3, then it should insert into the database 3 times, but instead it inserted into the database 6 times(if iCount is 4 then instead of inserting 4 times it inserted 8 times).
I did a Response.Write(""& iCount &""

But when I inserted the number directly--instead of
For iLoop = 0 to iCount I put
For iLoop = 0 to 3
then everything works fine... Please advice.
Thanks in advance!
JoJoH