Loop

Ø

Øyvind Isaksen

Hello!

I store from 1 to 50 (depending on input from user) image names in session
variables (not array), and put them in variables like this:

For X = 1 To 50
Execute("varImage_" & X & " = Session(""image_" & X & """)")
Next`

This work perfect, output is like this:
varImage_1 = session("image_1")
varImage_2 = session("image_2")
varImage_3 = session("image_3") and so on...



---Here is what I try to do:--------------

Now I'm stucked with almost the same "problem"... I need to create ut to 50
SQL's in a loop like the other code.
This code under will explain what I try to do, X shall go from 1 to 50. I
just need to get this correct:

For X = 1 To 50

if varImage_X <> "" then SQL_X = "insert into tblImage (path,sort,artID)
values ('"&varImage_X&"','X','"&dbArtID&"'); "

'Make variable SQL_SaveImgs with all the SQL's:
if varImage_X <> "" then SQL_SaveImgs = SQL_SaveImgs & SQL_X

Next

How can I do this so it works??

-------------------------------------------


Try to get this output:
if varImage_1 <> "" then SQL_X = "insert into tblImage (path,sort,artID)
values ('"&varImage_1&"','1','"&dbArtID&"'); "
if varImage_2 <> "" then SQL_X = "insert into tblImage (path,sort,artID)
values ('"&varImage_2&"','2','"&dbArtID&"'); "
if varImage_3 <> "" then SQL_X = "insert into tblImage (path,sort,artID)
values ('"&varImage_3&"','3','"&dbArtID&"'); " and so on....

if varImage_1 <> "" then SQL_SaveImgs = SQL_SaveImgs & SQL_1
if varImage_2 <> "" then SQL_SaveImgs = SQL_SaveImgs & SQL_2
if varImage_3 <> "" then SQL_SaveImgs = SQL_SaveImgs & SQL_3 and so on....

(Will later on use SQL_SaveImgs to save all images)

-------------------------------------------



Hope someone please can help me!!
Regards,
Mr Isaksen
 

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,262
Messages
2,571,059
Members
48,769
Latest member
Clifft

Latest Threads

Top