Ver Mensaje Individual
  #8 (permalink)  
Antiguo 14/03/2007, 22:49
Pelao
 
Fecha de Ingreso: abril-2003
Mensajes: 260
Antigüedad: 22 años
Puntos: 1
Re: Ayuda con Guardar,Modificar,Eliminar datos de una base de datos

estoy tratando de actualizar el campo BME pero me da el siguiente error al enviar el form

ADODB.Recordset (0x800A0CC1)
No se encontró el elemento en la colección que corresponde con el nombre o el ordinal pedido.
/tablero/detalles.asp, línea 52

aqui esta mi codigo

Código:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
Dim cnn, rcs, SQL
set cnn=Server.CreateObject("ADODB.Connection")
set rs=Server.CreateObject("ADODB.Recordset")
cnn.open "circulacion", "sa", ""


' Borrado / busqueda para actualizar
if request.QueryString("update") <> "" then
    set rs = cnn.execute("SELECT * FROM costos_maxirest WHERE bme = " & request.QueryString("update"))
end if

' Insercion / modificacion de registros
if request.Form("bme") <> "" then
    if request.Form("action") = "update" then
        sql = "UPDATE costos_maxirest SET bme = '" & request.Form("bme") & "'"
		sql = sql & " WHERE fecha = " & request.Form("fecha") ' Actualizar
		' Actualizar
    else
        ' Comprobamos que no exista
        Dim rsd
        set rsd = Server.CreateObject("ADODB.Recordset")
        set rsd = cnn.execute("SELECT bme FROM costos_maxirest WHERE bme = " & request.Form("bme"))
        existe = not rsd.EOF
        rsd.close()
    
        if not existe then
            sql = "INSERT INTO costos_maxirest (bme,fecha) VALUES ("
            sql = sql & ",'" & request.Form("bme") & "'"    
            sql = sql & ",'" & request.Form("fecha") & "'"  
        end if
        
    end if
end if

' Lo ideal es que controles el SQL injection
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin t&iacute;tulo</title>
</head>

<body>
<form id="form1" name="form1" method="post" action="detalles.asp">
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td>Fecha</td>
      <td><p>
        <input type="text" name="fecha" value="<% if isObject(rs) then response.Write(rs.fields("fecha").value)%>" />
      </p></td>
    </tr>
    <tr>
      <td>bme</td>
      <td><p>
        <input type="text" name="bme" value="<% if isObject(rs) then response.Write(rs.fields("bme").value)%>" />
        </p>      </td>
    </tr>
    <tr>
    </tr>
    <tr>
      <td colspan="2" align="center">
      <input type="hidden" name="action" value="<% if isObject(rs) then response.Write("update") else response.Write("insert") %>" />      
      
      <input type="submit" name="Submit" value="Enviar" /></td>
    </tr>
  </table>
</form>
</body>
</html>
__________________
Bye!

Última edición por Pelao; 15/03/2007 a las 00:12