% Response.expires = 0 Response.expiresabsolute = Now() - 1 Response.addHeader "pragma", "no-cache" Response.addHeader "cache-control", "private" Response.addHeader "cache-control", "no-cache" Response.addHeader "cache-control", "no-store" Response.CacheControl = "no-cache" %> <% ewCurSec = 0 ' Initialise ' User levels Const ewAllowAdd = 1 Const ewAllowDelete = 2 Const ewAllowEdit = 4 Const ewAllowView = 8 Const ewAllowList = 8 Const ewAllowReport = 8 Const ewAllowSearch = 8 Const ewAllowAdmin = 16 %> <% ' Initialize common variables x_idfavorito = Null: ox_idfavorito = Null x_Nombre = Null: ox_Nombre = Null x_Web = Null: ox_Web = Null x_Sector = Null: ox_Sector = Null x_Comentario = Null: ox_Comentario = Null %> <% Response.Buffer = True ' Load key from QueryString bCopy = True x_idfavorito = Request.QueryString("idfavorito") If x_idfavorito = "" Or IsNull(x_idfavorito) Then bCopy = False End If ' Get action sAction = Request.Form("a_add") If (sAction = "" Or IsNull(sAction)) Then If bCopy Then sAction = "C" ' Copy record Else sAction = "I" ' Display blank record End If Else ' Get fields from form x_idfavorito = Request.Form("x_idfavorito") x_Nombre = Request.Form("x_Nombre") x_Web = Request.Form("x_Web") x_Sector = Request.Form("x_Sector") x_Comentario = Request.Form("x_Comentario") End If ' Open connection to the database Set conn = Server.CreateObject("ADODB.Connection") conn.Open xDb_Conn_Str Select Case sAction Case "C": ' Get a record to display If Not LoadData() Then ' Load Record based on key Session("ewmsg") = "No se han encontrado registros" conn.Close ' Close Connection Set conn = Nothing Response.Clear Response.Redirect "recomendadas.asp" End If Case "A": ' Add If AddData() Then ' Add New Record Session("ewmsg") = "Nuevo Registro Aņadido Satisfactoriamente" conn.Close ' Close Connection Set conn = Nothing Response.Clear Response.Redirect "recomendadas.asp" Else End If End Select %>

enCieza.com, introducción de datos
| Recomendadas Volver a la Lista |
<% conn.Close ' Close Connection Set conn = Nothing %> <% '------------------------------------------------------------------------------- ' Function LoadData ' - Load Data based on Key Value ' - Variables setup: field variables Function LoadData() Dim sSql, rs, sWhere, sGroupBy, sHaving, sOrderBy sSql = "SELECT * FROM `favoritas`" sWhere = "" sGroupBy = "" sHaving = "" sOrderBy = "" If sWhere <> "" Then sWhere = sWhere & " AND " sWhere = sWhere & "(`idfavorito` = " & AdjustSql(x_idfavorito) & ")" sSql = sSql & " WHERE " & sWhere If sGroupBy <> "" Then sSql = sSql & " GROUP BY " & sGroupBy End If If sHaving <> "" Then sSql = sSql & " HAVING " & sHaving End If If sOrderBy <> "" Then sSql = sSql & " ORDER BY " & sOrderBy End If Set rs = Server.CreateObject("ADODB.Recordset") rs.Open sSql, conn If rs.Eof Then LoadData = False Else LoadData = True rs.MoveFirst ' Get the field contents x_idfavorito = rs("idfavorito") x_Nombre = rs("Nombre") x_Web = rs("Web") x_Sector = rs("Sector") x_Comentario = rs("Comentario") End If rs.Close Set rs = Nothing End Function %> <% '------------------------------------------------------------------------------- ' Function AddData ' - Add Data ' - Variables used: field variables Function AddData() Dim sSql, rs, sWhere, sGroupBy, sHaving, sOrderBy Dim bCheckKey, sSqlChk, sWhereChk sSql = "SELECT * FROM `favoritas`" sWhere = "" sGroupBy = "" sHaving = "" sOrderBy = "" ' Check for duplicate key bCheckKey = True sWhereChk = sWhere If x_idfavorito = "" Or IsNull(x_idfavorito) Then bCheckKey = False Else If sWhereChk <> "" Then sWhereChk = sWhereChk & " AND " sWhereChk = sWhereChk & "(`idfavorito` = " & AdjustSql(x_idfavorito) & ")" End If If bCheckKey Then sSqlChk = sSql & " WHERE " & sWhereChk Set rsChk = conn.Execute(sSqlChk) If Not rsChk.Eof Then Session("ewmsg") = "" rsChk.Close Set rsChk = Nothing AddData = False Exit Function End If rsChk.Close Set rsChk = Nothing End If ' Add New Record If sWhere <> "" Then sWhere = sWhere & " AND " sWhere = sWhere & "(0 = 1)" sSql = sSql & " WHERE " & sWhere If sGroupBy <> "" Then sSql = sSql & " GROUP BY " & sGroupBy End If If sHaving <> "" Then sSql = sSql & " HAVING " & sHaving End If If sOrderBy <> "" Then sSql = sSql & " ORDER BY " & sOrderBy End If Set rs = Server.CreateObject("ADODB.Recordset") rs.CursorLocation = 3 rs.Open sSql, conn, 1, 2 rs.AddNew ' Field Nombre sTmp = Trim(x_Nombre) If Trim(sTmp) = "" Then sTmp = Null rs("Nombre") = sTmp ' Field Web sTmp = Trim(x_Web) If Trim(sTmp) = "" Then sTmp = Null rs("Web") = sTmp ' Field Sector sTmp = Trim(x_Sector) If Trim(sTmp) = "" Then sTmp = Null rs("Sector") = sTmp ' Field Comentario sTmp = Trim(x_Comentario) If Trim(sTmp) = "" Then sTmp = Null rs("Comentario") = sTmp rs.Update rs.Close Set rs = Nothing AddData = True End Function %>