Thread: Insert issue?
View Single Post
  #1 (permalink)  
Old June 14th, 2005, 10:09 AM
cedwards cedwards is offline
Authorized User
 
Join Date: May 2005
Location: , WI, .
Posts: 57
Thanks: 0
Thanked 0 Times in 0 Posts
Default Insert issue?

Hi -

This is probably easy - I am using a Command object to insert 4 fields of data into a recordset - this recordset will be update with additional information later on- what I would like to happen is that if those four fileds are already located in the database it would not insert them.

Basically some type of if then statement - I am unsure on how to do it though.

Here is the insert code:

<%

if(Request.Cookies("freezer") <> "") then com_insert__varnamefreezer = Request.Cookies("freezer")

if(Request.Cookies("tower") <> "") then com_insert__varnametower = Request.Cookies("tower")

if(Request.Cookies("box") <> "") then com_insert__varnamebox = Request.Cookies("box")

if(Request.Form("location") <> "") then com_insert__varnameloc = Request.Form("location")

%>
<%

set com_insert = Server.CreateObject("ADODB.Command")
com_insert.ActiveConnection = MM_sample_tracking_STRING
com_insert.CommandText = "INSERT INTO tblsamples (Freezer, Tower, Box, Location) VALUES ('" + Replace(com_insert__varnamefreezer, "'", "''") + "', '" + Replace(com_insert__varnametower, "'", "''") + "', '" + Replace(com_insert__varnamebox, "'", "''") + "', '" + Replace(com_insert__varnameloc, "'", "''") + "') "
com_insert.CommandType = 1
com_insert.CommandTimeout = 0
com_insert.Prepared = true
com_insert.Execute()

%>

Thans for any help!

Chris

Reply With Quote