Forums

ASP

This topic is locked

Update a Record.

Posted 17 Mar 2005 14:55:56
1
has voted
17 Mar 2005 14:55:56 Robert Waggott posted:
Hi

I think i'm being really dumb, and its probably obvious.

But when i go to update a database with a form values i always get the message: 'The Original Recordset specified in this script was not found.'

I'm using access and dreamweaver mx. couldn't find help anywhere on the net.

Replies

Replied 17 Mar 2005 16:44:49
17 Mar 2005 16:44:49 Dave Thomas replied:
post your recordset and form code plz

regards

Dave Thomas
<b>DMX Zone Manager</b>
Replied 11 Dec 2007 15:27:02
11 Dec 2007 15:27:02 Thomas Tucker replied:
I have exactly the same error and would love to know the solution.
Replied 15 May 2009 17:44:30
15 May 2009 17:44:30 Tony Barkdull replied:
I have the exact same error. Here is my code

[code]
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/maininfo.asp" -->
<%
Dim main_edit
Dim main_edit_numRows

Set main_edit = Server.CreateObject("ADODB.Recordset"
main_edit.ActiveConnection = MM_maininfo_STRING
main_edit.Source = "SELECT * FROM dbo.tbl_maininfo"
main_edit.CursorType = 0
main_edit.CursorLocation = 2
main_edit.LockType = 1
main_edit.Open()

main_edit_numRows = 0
%>
<%
' *** 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") = "form1" And CStr(Request("MM_recordId") <> "" Then

MM_editConnection = MM_maininfo_STRING
MM_editTable = "dbo.tbl_maininfo"
MM_editColumn = "Asset Tag"
MM_recordId = "'" + Request.Form("MM_recordId" + "'"
MM_editRedirectUrl = ""
MM_fieldsStr = "pcname|value|asset|value|serial|value|hardware|value|location|value|user|value|locationcode|value|branch|value|category|value|costcenter|value|po|value|ddate|value|warranty|value|deployed|value|comments|value"
MM_columnsStr = "pcname|',none,''|[Asset Tag]|',none,''|[Serial Number]|',none,''|[Hardware Type]|',none,''|Location|',none,''|[User Name]|',none,''|[Location Code]|',none,''|[Branch Number]|',none,''|Category|',none,''|[Cost Center]|',none,''|[PO #]|',none,''|[Deployment Date]|',none,NULL|[Warranty Expiration]|',none,NULL|Deployed|',none,''|Comments|',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
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="www.w3.org/1999/xhtml">
<head>
<title>Software Asset Management</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="sam.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="ProperCase.js">
</script>
</head>

<body>
<!--#include file="sam_header.asp" -->
<p align="center" class="style3">&nbsp;</p>
<form id="form2" name="form2" method="get" action="maininfo_edit.asp">
<span class="style3">Enter PC Name </span>
<input name="pcname" type="text" id="pcname" />
<input type="submit" name="Submit" value="Submit" />
</form>
<p align="center" class="style5">Maininfo Edit </p>
<form ACTION="<%=MM_editAction%>" METHOD="POST" id="form1" name="form1">
<table width="600" border="1" align="center" bordercolor="#006600">
<tr class="style3">
<td width="250">Fields</td>
<td width="250">Data</td>
</tr>
<tr class="style1">
<td class="style2">PC Name </td>
<td><input name="pcname" type="text" id="pcname" value="<%=(main_edit.Fields.Item("pcname".Value)%>" /></td>
</tr>
<tr class="style1">
<td class="style2">Asset Tag </td>
<td><input name="asset" type="text" id="asset" value="<%=(main_edit.Fields.Item("Asset Tag".Value)%>" /></td>
</tr>
<tr class="style1">
<td class="style2">Serial Number </td>
<td><input name="serial" type="text" id="serial" value="<%=(main_edit.Fields.Item("Serial Number".Value)%>" /></td>
</tr>
<tr class="style1">
<td class="style2">Hardware Type </td>
<td><input name="hardware" type="text" id="hardware" value="<%=(main_edit.Fields.Item("Hardware Type".Value)%>" /></td>
</tr>
<tr class="style1">
<td class="style2">Location</td>
<td><input name="location" type="text" id="location" onfocus="this.value=toProperCase(this.value)" value="<%=(main_edit.Fields.Item("Location".Value)%>"/></td>
</tr>
<tr class="style1">
<td class="style2">User Name </td>
<td><input name="user" type="text" id="user" onfocus="this.value=toProperCase(this.value)" value="<%=(main_edit.Fields.Item("User Name".Value)%>"/></td>
</tr>
<tr class="style1">
<td class="style2">Location Code</td>
<td><input name="locationcode" type="text" id="locationcode" value="<%=(main_edit.Fields.Item("Location Code".Value)%>" /></td>
</tr>
<tr class="style1">
<td class="style2">Branch Number </td>
<td><input name="branch" type="text" id="branch" value="<%=(main_edit.Fields.Item("Branch Number".Value)%>" /></td>
</tr>
<tr class="style1">
<td class="style2">Category</td>
<td><input name="category" type="text" id="category" value="<%=(main_edit.Fields.Item("Category".Value)%>" /></td>
</tr>
<tr class="style1">
<td class="style2">Cost Center</td>
<td><input name="costcenter" type="text" id="costcenter" value="<%=(main_edit.Fields.Item("Cost Center".Value)%>" /></td>
</tr>
<tr class="style1">
<td class="style2">PO#</td>
<td><input name="po" type="text" id="po" value="<%=(main_edit.Fields.Item("PO #".Value)%>" /></td>
</tr>
<tr class="style1">
<td class="style2">Deployment Date </td>
<td><input name="ddate" type="text" id="ddate" value="<%=(main_edit.Fields.Item("Deployment Date".Value)%>" /></td>
</tr>
<tr class="style1">
<td class="style2">Warranty Expiration </td>
<td><p>
<label></label>
<input name="warranty" type="text" id="warranty" value="<%=(main_edit.Fields.Item("Warranty Expiration".Value)%>" />
<br />
</p></td>
</tr>
<tr class="style1">
<td class="style2">Deployed</td>
<td><label>
<input name="deployed" type="text" id="deployed" value="<%=(main_edit.Fields.Item("Deployed".Value)%>" size="5" />
</label>
<label></label></td>
</tr>
<tr class="style1">
<td class="style2">Comments</td>
<td><textarea name="comments" cols="50" rows="5" id="comments"><%=(main_edit.Fields.Item("Comments".Value)%></textarea></td>
</tr>
<tr class="style1">
<td colspan="2"><div align="center">
<input type="submit" name="Submit2" value="Submit" />
</div></td>
</tr>
</table>


<input type="hidden" name="MM_update" value="form1">
<input type="hidden" name="MM_recordId" value="<%= main_edit.Fields.Item("Asset Tag".Value %>">
</form>

<p align="center">&nbsp;</p>
<!--#include file="footer.asp" -->
</body>
</html>
<%
main_edit.Close()
Set main_edit = Nothing
%>

{end code]

Reply to this topic