Forums
This topic is locked
Update Record behavior
Posted 06 May 2005 18:13:45
1
has voted
06 May 2005 18:13:45 Arturo Civit posted:
hi there, I'm trying to update a record from a database but I don´t know how to do this from the new version because the behavior window it's different, I'm choosing the record to be updated from a list of records, linking the record with the ID with: modificaroaxaca.asp?ID=<%=(Recordset1.Fields.Item("ID".Value)%>, then, in the next ASP document I've all the data to be updated but the Update record behavior it's different from other versions, I don't know what to do with for example Unique Key Column thing, and my document it's not updating nothing just click in the update record button and goes to the same document without go to my checkdata page ( it's like a refresh every time I hit the Update button ), any help?Here's my code, thanks in advance!!
<pre id=code><font face=courier size=2 id=code>
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="../Connections/CinemaxSite.asp" -->
<%
' *** Edit Operations: declare variables
Dim MM_editAction
Dim MM_abortEdit
Dim MM_editQuery
Dim MM_editCmd
Dim MM_editConnection
Dim MM_editTable
Dim MM_editRedirectUrl
Dim MM_editColumn
Dim MM_recordId
Dim MM_fieldsStr
Dim MM_columnsStr
Dim MM_fields
Dim MM_columns
Dim MM_typeArray
Dim MM_formVal
Dim MM_delim
Dim MM_altVal
Dim MM_emptyVal
Dim MM_i
MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME")
If (Request.QueryString <> "" Then
MM_editAction = MM_editAction & "?" & Server.HTMLEncode(Request.QueryString)
End If
' boolean to abort record edit
MM_abortEdit = false
' query string to execute
MM_editQuery = ""
%>
<%
' *** Update Record: set variables
If (CStr(Request("MM_update") = "form012" And CStr(Request("MM_recordId") <> "" Then
MM_editConnection = MM_CinemaxSite_STRING
MM_editTable = "Durango"
MM_editColumn = "ID"
MM_recordId = "" + Request.Form("MM_recordId" + ""
MM_editRedirectUrl = "checkdata.asp"
MM_fieldsStr = "NombreSpanish|value|NombreEnglish|value|Clasificacion|value|Pais|value|FechaRelease|value|Director|value|Reparto|value|SitioOficial|value|Horarios|value|Sinopsis|value"
MM_columnsStr = "NombreSpanish|',none,''|NombreEnglish|',none,''|Clasificacion|',none,''|Pais|',none,''|FechaRelease|',none,''|Director|',none,''|Reparto|',none,''|SitioOficial|',none,''|Horarios|',none,''|Sinopsis|',none,''"
' create the MM_fields and MM_columns arrays
MM_fields = Split(MM_fieldsStr, "|"
MM_columns = Split(MM_columnsStr, "|"
' set the form values
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_fields(MM_i+1) = CStr(Request.Form(MM_fields(MM_i)))
Next
' append the query string to the redirect URL
If (MM_editRedirectUrl <> "" And Request.QueryString <> "" Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "" Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
End If
End If
End If
%>
<%
' *** Update Record: construct a sql update statement and execute it
If (CStr(Request("MM_update") <> "" And CStr(Request("MM_recordId") <> "" Then
' create the sql update statement
MM_editQuery = "update " & MM_editTable & " set "
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_formVal = MM_fields(MM_i+1)
MM_typeArray = Split(MM_columns(MM_i+1),","
MM_delim = MM_typeArray(0)
If (MM_delim = "none" Then MM_delim = ""
MM_altVal = MM_typeArray(1)
If (MM_altVal = "none" Then MM_altVal = ""
MM_emptyVal = MM_typeArray(2)
If (MM_emptyVal = "none" Then MM_emptyVal = ""
If (MM_formVal = "" Then
MM_formVal = MM_emptyVal
Else
If (MM_altVal <> "" Then
MM_formVal = MM_altVal
ElseIf (MM_delim = "'" Then ' escape quotes
MM_formVal = "'" & Replace(MM_formVal,"'","''" & "'"
Else
MM_formVal = MM_delim + MM_formVal + MM_delim
End If
End If
If (MM_i <> LBound(MM_fields)) Then
MM_editQuery = MM_editQuery & ","
End If
MM_editQuery = MM_editQuery & MM_columns(MM_i) & " = " & MM_formVal
Next
MM_editQuery = MM_editQuery & " where " & MM_editColumn & " = " & MM_recordId
If (Not MM_abortEdit) Then
' execute the update
Set MM_editCmd = Server.CreateObject("ADODB.Command"
MM_editCmd.ActiveConnection = MM_editConnection
MM_editCmd.CommandText = MM_editQuery
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close
If (MM_editRedirectUrl <> "" Then
Response.Redirect(MM_editRedirectUrl)
End If
End If
End If
%>
<%
Dim Recordset1__MMColParam
Recordset1__MMColParam = "1"
If (Request.QueryString("ID" <> "" Then
Recordset1__MMColParam = Request.QueryString("ID"
End If
%>
<%
Dim Recordset1
Dim Recordset1_numRows
Set Recordset1 = Server.CreateObject("ADODB.Recordset"
Recordset1.ActiveConnection = MM_CinemaxSite_STRING
Recordset1.Source = "SELECT * FROM Durango WHERE ID = " + Replace(Recordset1__MMColParam, "'", "''" + ""
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()
Recordset1_numRows = 0
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>.: Administrador MultiMax :. .: Modificar carterlera :.</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
body {
background-image: url(images/fondo.jpg);
}
.style16 {color: #bdac6d; font-family: Arial, Helvetica, sans-serif; font-size: 14px; font-weight: bold; }
.style8 {font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
color: #FFFFFF;
}
-->
</style></head>
<body>
<div align="center">
<form ACTION="<%=MM_editAction%>" METHOD="POST" enctype="multipart/form-data" name="form012" id="form012">
<table width="545" border="0" cellpadding="0" cellspacing="2">
<tr align="center">
<td height="50" colspan="7" valign="top" background="images/fondo_tit.jpg"><img src="images/trans.gif" width="540" height="15"><br>
<span class="style16">Modificar Cartelera Durango </span></td>
</tr>
<tr align="center" valign="top">
<td colspan="7" bgcolor="#2D4C61"><table width="400" border="0" cellpadding="2" cellspacing="2" bgcolor="#2D4C61">
<tr>
<td width="141" class="style8"><div align="left">Nombre en Español </div></td>
<td width="245"><div align="left">
<input name="NombreSpanish" type="text" id="NombreSpanish22" value="<%=(Recordset1.Fields.Item("NombreSpanish".Value)%>" size="32">
</div></td>
</tr>
<tr>
<td class="style8"><div align="left">Nombre en Inglés </div></td>
<td><div align="left">
<input name="NombreEnglish" type="text" id="NombreEnglish22" value="<%=(Recordset1.Fields.Item("NombreEnglish".Value)%>" size="32">
</div></td>
</tr>
<tr>
<td class="style8"><div align="left">Clasificacion</div></td>
<td><div align="left">
<input name="Clasificacion" type="text" id="Clasificacion22" value="<%=(Recordset1.Fields.Item("Clasificacion".Value)%>" size="32">
</div></td>
</tr>
<tr>
<td class="style8"><div align="left">Pais</div></td>
<td><div align="left">
<input name="Pais" type="text" id="Pais22" value="<%=(Recordset1.Fields.Item("Pais".Value)%>" size="32">
</div></td>
</tr>
<tr>
<td class="style8"><div align="left">Año de Creación </div></td>
<td><div align="left">
<input name="FechaRelease" type="text" id="FechaRelease22" value="<%=(Recordset1.Fields.Item("FechaRelease".Value)%>" size="32">
</div></td>
</tr>
<tr>
<td class="style8"><div align="left">Director</div></td>
<td><div align="left">
<input name="Director" type="text" id="Director22" value="<%=(Recordset1.Fields.Item("Director".Value)%>" size="32">
</div></td>
</tr>
<tr>
<td class="style8"><div align="left">Reparto</div></td>
<td><div align="left">
<input name="Reparto" type="text" id="Reparto22" value="<%=(Recordset1.Fields.Item("Reparto".Value)%>" size="32">
</div></td>
</tr>
<tr>
<td class="style8"><div align="left">Sitio Oficial </div></td>
<td><div align="left">
<input name="SitioOficial" type="text" id="SitioOficial22" value="<%=(Recordset1.Fields.Item("SitioOficial".Value)%>" size="32">
</div></td>
</tr>
<tr>
<td class="style8"><div align="left">Horarios</div></td>
<td><div align="left">
<input name="Horarios" type="text" id="Horarios22" value="<%=(Recordset1.Fields.Item("Horarios".Value)%>" size="32">
</div></td>
</tr>
<tr>
<td valign="top" class="style8"><div align="left">Sinopsis</div></td>
<td><div align="left">
<textarea name="Sinopsis" cols="32" id="textarea2"><%=(Recordset1.Fields.Item("Sinopsis".Value)%></textarea>
</div></td>
</tr>
<tr>
<td colspan="2"><div align="center">
<input type="submit" name="Submit2" value="Modificar Cartelera">
</div></td>
</tr>
</table></td>
</tr>
</table>
<input type="hidden" name="MM_update" value="form012">
<input type="hidden" name="MM_recordId" value="<%= Recordset1.Fields.Item("ID".Value %>">
</form>
<p> </p>
</div>
</body>
</html>
<%
Recordset1.Close()
Set Recordset1 = Nothing
%></font id=code></pre id=code>
Replies
Replied 06 May 2005 18:59:19
06 May 2005 18:59:19 Chris Charlton replied:
What version of DW did you come from, and are now in?
~ ~ ~ ~ ~ ~ ~
Chris Charlton <i>- DMXzone Manager</i>
<font size=1>[ Studio MX/MX2004 | PHP/ASP | SQL | XHTML/CSS | XML | Actionscript | Web Accessibility | MX Extensibility ]</font id=size1>
~ ~ ~ ~ ~ ~ ~
Chris Charlton <i>- DMXzone Manager</i>
<font size=1>[ Studio MX/MX2004 | PHP/ASP | SQL | XHTML/CSS | XML | Actionscript | Web Accessibility | MX Extensibility ]</font id=size1>
Replied 06 May 2005 19:36:48
06 May 2005 19:36:48 Dan Berdusco replied:
Remove the text <b>enctype="multipart/form-data"</b>. This will cause this error - (you only need this if you have a file field).
Edited by - flexman44 on 06 May 2005 19:38:28
Edited by - flexman44 on 06 May 2005 19:38:28
Replied 06 May 2005 19:40:17
06 May 2005 19:40:17 Arturo Civit replied:
i was using DWMX, now I'm using DWMX04, the problem is the document should work, but it's not working, idon´t know if there's a problem with the ID thing, i don´t know, I'm newbie with ASP
<img src=../images/dmxzone/forum/icon_smile_sad.gif border=0 align=middle>
<img src=../images/dmxzone/forum/icon_smile_sad.gif border=0 align=middle>
Replied 06 May 2005 19:56:11
06 May 2005 19:56:11 Arturo Civit replied:
Trevor, i don´t know how to say thanks, now it's working, Really Really thanks!!!
Arturo
Arturo