% If Session("project1_status") <> "login" Then Response.Redirect "login.asp" %> <% Response.expires = 0 Response.expiresabsolute = Now() - 1 Response.addHeader "pragma", "no-cache" Response.addHeader "cache-control", "private" Response.CacheControl = "no-cache" %> <% Response.Buffer = True key = Request.Querystring("key") If key = "" Or IsNull(key) Then key = Request.Form("key") If key = "" Or IsNull(key) Then Response.Redirect "contactslist.asp" ' Get action a = Request.Form("a") If a = "" Or IsNull(a) Then a = "I" ' Display with input box End If ' Get fields from form x_contactID = Request.Form("x_contactID") x_datestamp = Request.Form("x_datestamp") x_inquirytype = Request.Form("x_inquirytype") x_other = Request.Form("x_other") x_timeframe = Request.Form("x_timeframe") x_name = Request.Form("x_name") x_street = Request.Form("x_street") x_city = Request.Form("x_city") x_state = Request.Form("x_state") x_zip = Request.Form("x_zip") x_daytimephone = Request.Form("x_daytimephone") x_eveningphone = Request.Form("x_eveningphone") x_email = Request.Form("x_email") x_besttimetocontact = Request.Form("x_besttimetocontact") x_comments = Request.Form("x_comments") x_notes = Request.Form("x_notes") ' Open Connection to the database Set conn = Server.CreateObject("ADODB.Connection") conn.Open xDb_Conn_Str Select Case a Case "I": ' Get a record to display tkey = "" & key & "" strsql = "SELECT * FROM [contacts] WHERE [contactID]=" & tkey Set rs = Server.CreateObject("ADODB.Recordset") rs.Open strsql, conn If rs.Eof Then Response.Clear Response.Redirect "contactslist.asp" Else rs.MoveFirst End If ' Get the field contents x_contactID = rs("contactID") x_datestamp = rs("datestamp") x_inquirytype = rs("inquirytype") x_other = rs("other") x_timeframe = rs("timeframe") x_name = rs("name") x_street = rs("street") x_city = rs("city") x_state = rs("state") x_zip = rs("zip") x_daytimephone = rs("daytimephone") x_eveningphone = rs("eveningphone") x_email = rs("email") x_besttimetocontact = rs("besttimetocontact") x_comments = rs("comments") x_notes = rs("notes") rs.Close Set rs = Nothing Case "U": ' Update ' Open record tkey = "" & key & "" strsql = "SELECT * FROM [contacts] WHERE [contactID]=" & tkey Set rs = Server.CreateObject("ADODB.Recordset") rs.Open strsql, conn, 1, 2 If rs.Eof Then Response.Clear Response.Redirect "contactslist.asp" End If tmpFld = x_datestamp If IsDate(tmpFld) Then rs("datestamp") = CDate(tmpFld) Else rs("datestamp") = Null End If tmpFld = Trim(x_inquirytype) If Trim(tmpFld) & "x" = "x" Then tmpFld = Null rs("inquirytype") = tmpFld tmpFld = Trim(x_other) If Trim(tmpFld) & "x" = "x" Then tmpFld = Null rs("other") = tmpFld tmpFld = Trim(x_timeframe) If Trim(tmpFld) & "x" = "x" Then tmpFld = Null rs("timeframe") = tmpFld tmpFld = Trim(x_name) If Trim(tmpFld) & "x" = "x" Then tmpFld = Null rs("name") = tmpFld tmpFld = Trim(x_street) If Trim(tmpFld) & "x" = "x" Then tmpFld = Null rs("street") = tmpFld tmpFld = Trim(x_city) If Trim(tmpFld) & "x" = "x" Then tmpFld = Null rs("city") = tmpFld tmpFld = Trim(x_state) If Trim(tmpFld) & "x" = "x" Then tmpFld = Null rs("state") = tmpFld tmpFld = Trim(x_zip) If Trim(tmpFld) & "x" = "x" Then tmpFld = Null rs("zip") = tmpFld tmpFld = Trim(x_daytimephone) If Trim(tmpFld) & "x" = "x" Then tmpFld = Null rs("daytimephone") = tmpFld tmpFld = Trim(x_eveningphone) If Trim(tmpFld) & "x" = "x" Then tmpFld = Null rs("eveningphone") = tmpFld tmpFld = Trim(x_email) If Trim(tmpFld) & "x" = "x" Then tmpFld = Null rs("email") = tmpFld tmpFld = Trim(x_besttimetocontact) If Trim(tmpFld) & "x" = "x" Then tmpFld = Null rs("besttimetocontact") = tmpFld tmpFld = Trim(x_comments) If Trim(tmpFld) & "x" = "x" Then tmpFld = Null rs("comments") = tmpFld tmpFld = Trim(x_notes) If Trim(tmpFld) & "x" = "x" Then tmpFld = Null rs("notes") = tmpFld rs.Update rs.Close Set rs = Nothing conn.Close Set conn = Nothing Response.Clear Response.Redirect "contactslist.asp" End Select %>
Edit TABLE: contacts
Back to List