Insert Issue revisited
Hi Imar,
The insert code worked perfectly - however I have another dilemma on that page. I would like to also update a record on the same page as the insert - is this possible? I have found that I cannot seem to get it to work. I am getting error like: data type mismatch and sometime file locked by server. Here is a copy of the update code if that will help:
<%
if(Request.Form("upn") <> "") then Comupdate__varupn = Request.Form("upn")
if(Request.Form("upna") <> "") then Comupdate__varupna = Request.Form("upna")
if(Request.Form("date_drawn") <> "") then Comupdate__vardate_drawn = Request.Form("date_drawn")
if(Request.Form("date_drawn") <> "") then Comupdate__vardate_stored = Request.Form("date_drawn")
if(Request.Form("person_storing") <> "") then Comupdate__varperson_storing = Request.Form("person_storing")
if(Request.Form("total_vials") <> "") then Comupdate__vartotal_vials = Request.Form("total_vials")
if(Request.Form("freezing_Method") <> "") then Comupdate__varfreezing_method = Request.Form("freezing_Method")
if(Request.Form("comments") <> "") then Comupdate__varcomments = Request.Form("comments")
if(Request.Cookies("freezer") <> "") then Comupdate__varnamefreezer = Request.Cookies("freezer")
if(Request.Cookies("tower") <> "") then Comupdate__varnametower = Request.Cookies("tower")
if(Request.Cookies("box") <> "") then Comupdate__varnamebox = Request.Cookies("box")
if(Request.Cookies("location") <> "") then Comupdate__varnameloc = Request.Cookies("location")
%>
<%
set Comupdate = Server.CreateObject("ADODB.Command")
Comupdate.ActiveConnection = MM_sample_tracking_STRING
Comupdate.CommandText = "UPDATE tblsamples SET UPN= '" + Replace(Comupdate__varupn, "'", "''") + "' and UPNA='" + Replace(Comupdate__varupna, "'", "''") + "' and Date_Drawn='" + Replace(Comupdate__vardate_drawn, "'", "''") + "' and Date_stored='" + Replace(Comupdate__vardate_stored, "'", "''") + "' and Person_Storing='" + Replace(Comupdate__varperson_storing, "'", "''") + "' and Total_Vials= '" + Replace(Comupdate__vartotal_vials, "'", "''") + "' and Freezing_Method= '" + Replace(Comupdate__varfreezing_method, "'", "''") + "' and Comments='" + Replace(Comupdate__varcomments, "'", "''") + "' WHERE Freezer='" + Replace(Comupdate__varnamefreezer, "'", "''") + "' and Tower='" + Replace(Comupdate__varnametower, "'", "''") + "' and Box='" + Replace(Comupdate__varnamebox, "'", "''") + "' and Location='" + Replace(Comupdate__varnameloc, "'", "''") + "' "
Comupdate.CommandType = 1
Comupdate.CommandTimeout = 0
Comupdate.Prepared = true
Comupdate.Execute()
%>
As far as the code is concerned it is nearly identical to the insert statement - but I just seem to get a bunch of errors. I know Dreamweaver doesn't like multiple insert/update - but I have done it in the past.
As ever - I appreciate any input.
Chris
|