|
|
 |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Dreamweaver (all versions) section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.
|
 |
|

June 16th, 2005, 04:58 PM
|
|
Authorized User
|
|
Join Date: May 2005
Location: , WI, .
Posts: 57
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Here it is:
<p align="center"><span class="text">Additional Locations:
<select name="locations" size="3" multiple id="locations">
<option value="001">001</option>
<option value="002">002</option>
<option value="003">003</option>
<option value="004">004</option>
<option value="005">005</option>
</select>
|

June 16th, 2005, 05:06 PM
|
 |
Wrox Author
Points: 33,170, Level: 79 |
|
|
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 10,161
Thanks: 7
Thanked 188 Times in 186 Posts
|
|
What happens when you modify the loop like this:
Code:
Response.Write("Location is " & Request.Form("locations") & "<br />")
For Each location In Request.Form("locations")
set cominsert = Server.CreateObject("ADODB.Command")
cominsert.ActiveConnection = MM_sample_tracking_STRING
cominsert.CommandText = "INSERT INTO tblsamples (Freezer, Tower, Box, Location, UPN, UPNA, Date_Drawn, Date_Stored, Person_Storing, Total_Vials, Freezing_Method, Comments) VALUES ('" + Replace(cominsert__varfreezer, "'", "''") + "', '" + Replace(cominsert__vartower, "'", "''") + "', '" + Replace(cominsert__varbox, "'", "''") + "', '" + Replace(cominsert__varlocation, "'", "''") + "', '" + Replace(cominsert__varupn, "'", "''") + "', '" + Replace(cominsert__varupna, "'", "''") + "', '" + Replace(cominsert__vardate_drawn, "'", "''") + "', '" + Replace(cominsert__vardate_stored, "'", "''") + "', '" + Replace(cominsert__varperson_storing, "'", "''") + "', '" + Replace(cominsert__vartotal_vials, "'", "''") + "', '" + Replace(cominsert__varfreezing_method, "'", "''") + "', '" + Replace(cominsert__varcomments, "'", "''") + "') "
'cominsert.CommandType = 1
'cominsert.CommandTimeout = 0
'cominsert.Prepared = true
'cominsert.Execute()
Response.Write("Sql Statement is " & cominsert.CommandText & "<br />")
Next
What do you get? Multiple Sql statements?
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
|

June 16th, 2005, 05:28 PM
|
|
Authorized User
|
|
Join Date: May 2005
Location: , WI, .
Posts: 57
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Sent you an email with the output. Can't seem to get the forum reply to work right now.
|

June 16th, 2005, 05:31 PM
|
|
Authorized User
|
|
Join Date: May 2005
Location: , WI, .
Posts: 57
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
OOPS - forum is working just fine - the screen has been stretched though! Here is the output:
' 'Location is 001, 002, 003, 005, 006
Sql Statement is INSERT INTO tblsamples (Freezer, Tower, Box, Location, UPN, UPNA, Date_Drawn, Date_Stored, Person_Storing, Total_Vials, Freezing_Method, Comments) VALUES ('Cryo-3', '16', 'E', '001, 002, 003, 005, 006', '001', 'A', '06/16/2005', '06/16/2005', 'name', '', 'Control Rate', '')
Sql Statement is INSERT INTO tblsamples (Freezer, Tower, Box, Location, UPN, UPNA, Date_Drawn, Date_Stored, Person_Storing, Total_Vials, Freezing_Method, Comments) VALUES ('Cryo-3', '16', 'E', '001, 002, 003, 005, 006', '001', 'A', '06/16/2005', '06/16/2005', 'name', '', 'Control Rate', '')
Sql Statement is INSERT INTO tblsamples (Freezer, Tower, Box, Location, UPN, UPNA, Date_Drawn, Date_Stored, Person_Storing, Total_Vials, Freezing_Method, Comments) VALUES ('Cryo-3', '16', 'E', '001, 002, 003, 005, 006', '001', 'A', '06/16/2005', '06/16/2005', 'name', '', 'Control Rate', '')
Sql Statement is INSERT INTO tblsamples (Freezer, Tower, Box, Location, UPN, UPNA, Date_Drawn, Date_Stored, Person_Storing, Total_Vials, Freezing_Method, Comments) VALUES ('Cryo-3', '16', 'E', '001, 002, 003, 005, 006', '001', 'A', '06/16/2005', '06/16/2005', 'name', '', 'Control Rate', '')
Sql Statement is INSERT INTO tblsamples (Freezer, Tower, Box, Location, UPN, UPNA, Date_Drawn, Date_Stored, Person_Storing, Total_Vials, Freezing_Method, Comments) VALUES ('Cryo-3', '16', 'E', '001, 002, 003, 005, 006', '001', 'A', '06/16/2005', '06/16/2005', 'name', '', 'Control Rate', '')
I am not sure if this will help or not. Looks like it is looping - but the all of the selections seem to be entered into the database.
Chris
|

June 17th, 2005, 02:20 AM
|
 |
Wrox Author
Points: 33,170, Level: 79 |
|
|
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 10,161
Thanks: 7
Thanked 188 Times in 186 Posts
|
|
I think this is the problem:
Code:
if(Request.Form("locations") <> "") then cominsert__varlocation = Request.Form("locations")
You assign the value of Request.Form("locations") to cominsert__varlocation. However, the locations is now a form item that can have multiple items. So, you should no longer store it in cominsert__varlocation, but use location in your query instead:
Code:
cominsert.CommandText = "INSERT INTO tblsamples (Freezer, Tower, Box, Location, UPN, UPNA, Date_Drawn, Date_Stored, Person_Storing,
Total_Vials, Freezing_Method, Comments) VALUES ('" + Replace
(cominsert__varfreezer, "'", "''") + "', '" + Replace
(cominsert__vartower, "'", "''") + "', '" + Replace
(cominsert__varbox, "'", "''") + "', '" + Replace
(location, "'", "''") + "', '" + Replace
(cominsert__varupn, "'", "''") + "', '" + Replace
(cominsert__varupna, "'", "''") + "', '" + Replace
(cominsert__vardate_drawn, "'", "''") + "', '" + Replace
(cominsert__vardate_stored, "'", "''") + "', '" + Replace
(cominsert__varperson_storing, "'", "''") + "', '" + Replace
(cominsert__vartotal_vials, "'", "''") + "', '" + Replace
(cominsert__varfreezing_method, "'", "''") + "', '" + Replace
(cominsert__varcomments, "'", "''") + "') "
Does that make sense? instead of the comma separated form value (e.g. 001, 002, 003) you know use each location in the loop (e.g. 001, then 002, and in he next iteration 003 and so on).
If you look at the output you posted, you can see that it's executing 6 identical queries. By making the above changes, I think that should be fixed.
Can you please start a new thread if you have more questions? We ruined this one a bit with all those way too long queries.... I can hardly read it anymore....
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |