Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Dreamweaver (all versions) section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 16th, 2005, 03:58 PM
Authorized User
 
Join Date: May 2005
Location: , WI, .
Posts: 57
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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>

 
Old June 16th, 2005, 04:06 PM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

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.
 
Old June 16th, 2005, 04:28 PM
Authorized User
 
Join Date: May 2005
Location: , WI, .
Posts: 57
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sent you an email with the output. Can't seem to get the forum reply to work right now.

 
Old June 16th, 2005, 04:31 PM
Authorized User
 
Join Date: May 2005
Location: , WI, .
Posts: 57
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
 
Old June 17th, 2005, 01:20 AM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

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.




Similar Threads
Thread Thread Starter Forum Replies Last Post
Sql Insert -- date format issue feets Access VBA 2 June 12th, 2007 12:11 PM
Insert Issue into Acces DB brawny4 Visual Basic 2005 Basics 2 February 21st, 2007 08:43 PM
Ch10 - issue with insert in log table Cata BOOK: Professional SQL Server 2005 Administration ISBN: 0-470-05520-0 0 February 15th, 2007 05:17 PM
trigger to insert current date on insert kev_79 SQL Server 2000 3 January 23rd, 2006 05:58 PM
Insert Issue revisited cedwards Dreamweaver (all versions) 13 June 21st, 2005 03:02 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.