ultradev - update record
Hvad gør jeg forkert? Jeg opdatere kun 1 RS men benytter fire til at lave dropdown selection mulighed og dette burde ikke have indflydelse så lang tid jeg kun sender til 1 RS! Jeg havde det samme problem med insert: http://www.eksperten.dk/spm/106923Microsoft OLE DB Provider for ODBC Drivers error \'80004005\'
[Microsoft][ODBC Microsoft Access Driver] Operation must use an updateable query.
/modularisering/update.asp, line 89
HER ER KODEN
<%@LANGUAGE=\"VBSCRIPT\"%>
<!--#include file=\"Connections/data.asp\" -->
<%
\' *** Edit Operations: declare variables
MM_editAction = CStr(Request(\"URL\"))
If (Request.QueryString <> \"\") Then
MM_editAction = MM_editAction & \"?\" & 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\")) <> \"\" And CStr(Request(\"MM_recordId\")) <> \"\") Then
MM_editConnection = MM_data_STRING
MM_editTable = \"tbl_web\"
MM_editColumn = \"id\"
MM_recordId = \"\" + Request.Form(\"MM_recordId\") + \"\"
MM_editRedirectUrl = \"index.asp\"
MM_fieldsStr = \"broadcast|value|sprog|value|overskrift|value|kort_beskrivelse|value|lang_beskrivelse|value|links|value\"
MM_columnsStr = \"broadcast|none,none,NULL|sprog|\',none,\'\'|overskrift|\',none,\'\'|kort_beskrivelse|\',none,\'\'|lang_beskrivelse|\',none,\'\'|links|\',none,\'\'\"
\' create the MM_fields and MM_columns arrays
MM_fields = Split(MM_fieldsStr, \"|\")
MM_columns = Split(MM_columnsStr, \"|\")
\' set the form values
For i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_fields(i+1) = CStr(Request.Form(MM_fields(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 i = LBound(MM_fields) To UBound(MM_fields) Step 2
FormVal = MM_fields(i+1)
MM_typeArray = Split(MM_columns(i+1),\",\")
Delim = MM_typeArray(0)
If (Delim = \"none\") Then Delim = \"\"
AltVal = MM_typeArray(1)
If (AltVal = \"none\") Then AltVal = \"\"
EmptyVal = MM_typeArray(2)
If (EmptyVal = \"none\") Then EmptyVal = \"\"
If (FormVal = \"\") Then
FormVal = EmptyVal
Else
If (AltVal <> \"\") Then
FormVal = AltVal
ElseIf (Delim = \"\'\") Then \' escape quotes
FormVal = \"\'\" & Replace(FormVal,\"\'\",\"\'\'\") & \"\'\"
Else
FormVal = Delim + FormVal + Delim
End If
End If
If (i <> LBound(MM_fields)) Then
MM_editQuery = MM_editQuery & \",\"
End If
MM_editQuery = MM_editQuery & MM_columns(i) & \" = \" & 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 rs_indhold__MMColParam
rs_indhold__MMColParam = \"1\"
if (Request.QueryString(\"id\") <> \"\") then rs_indhold__MMColParam = Request.QueryString(\"id\")
%>
<%
set rs_indhold = Server.CreateObject(\"ADODB.Recordset\")
rs_indhold.ActiveConnection = MM_data_STRING
rs_indhold.Source = \"SELECT * FROM tbl_web WHERE id = \" + Replace(rs_indhold__MMColParam, \"\'\", \"\'\'\") + \"\"
rs_indhold.CursorType = 0
rs_indhold.CursorLocation = 2
rs_indhold.LockType = 3
rs_indhold.Open()
rs_indhold_numRows = 0
%>
<%
set rs_teknologi = Server.CreateObject(\"ADODB.Recordset\")
rs_teknologi.ActiveConnection = MM_data_STRING
rs_teknologi.Source = \"SELECT Distinct teknologi FROM tbl_web\"
rs_teknologi.CursorType = 0
rs_teknologi.CursorLocation = 2
rs_teknologi.LockType = 3
rs_teknologi.Open()
rs_teknologi_numRows = 0
%>
<%
set rs_ydelse = Server.CreateObject(\"ADODB.Recordset\")
rs_ydelse.ActiveConnection = MM_data_STRING
rs_ydelse.Source = \"SELECT Distinct ydelse FROM tbl_web\"
rs_ydelse.CursorType = 0
rs_ydelse.CursorLocation = 2
rs_ydelse.LockType = 3
rs_ydelse.Open()
rs_ydelse_numRows = 0
%>
<%
set rs_intgr = Server.CreateObject(\"ADODB.Recordset\")
rs_intgr.ActiveConnection = MM_data_STRING
rs_intgr.Source = \"SELECT Distinct intgr FROM tbl_web\"
rs_intgr.CursorType = 0
rs_intgr.CursorLocation = 2
rs_intgr.LockType = 3
rs_intgr.Open()
rs_intgr_numRows = 0
%>
<%
set rs_gfx = Server.CreateObject(\"ADODB.Recordset\")
rs_gfx.ActiveConnection = MM_data_STRING
rs_gfx.Source = \"SELECT Distinct gfx FROM tbl_web\"
rs_gfx.CursorType = 0
rs_gfx.CursorLocation = 2
rs_gfx.LockType = 3
rs_gfx.Open()
rs_gfx_numRows = 0
%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">
</head>
<body bgcolor=\"#FFFFFF\" text=\"#000000\">
<form method=\"POST\" action=\"<%=MM_editAction%>\" name=\"form3\">
<table align=\"center\">
<tr valign=\"baseline\">
<td nowrap align=\"right\">id:</td>
<td><%=(rs_indhold.Fields.Item(\"id\").Value)%> </td>
</tr>
<tr valign=\"baseline\">
<td nowrap align=\"right\">Broadcast:</td>
<td>
<input type=\"text\" name=\"broadcast\" value=\"<%=(rs_indhold.Fields.Item(\"broadcast\").Value)%>\" size=\"32\">
</td>
</tr>
<tr valign=\"baseline\">
<td nowrap align=\"right\">Sprog:</td>
<td>
<input type=\"text\" name=\"sprog\" value=\"<%=(rs_indhold.Fields.Item(\"sprog\").Value)%>\" size=\"32\">
</td>
</tr>
<tr valign=\"baseline\">
<td nowrap align=\"right\">Teknologi:</td>
<td>
<select name=\"select\">
<%
While (NOT rs_teknologi.EOF)
%>
<option value=\"<%=(rs_teknologi.Fields.Item(\"teknologi\").Value)%>\" ><%=(rs_teknologi.Fields.Item(\"teknologi\").Value)%></option>
<option value=\"<%=(rs_teknologi.Fields.Item(\"teknologi\").Value)%>\" selected ><%=(rs_indhold.Fields.Item(\"teknologi\").Value)%></option>
<%
rs_teknologi.MoveNext()
Wend
If (rs_teknologi.CursorType > 0) Then
rs_teknologi.MoveFirst
Else
rs_teknologi.Requery
End If
%>
</select>
</td>
</tr>
<tr valign=\"baseline\">
<td nowrap align=\"right\">Ydelse:</td>
<td>
<select name=\"select2\">
<%
While (NOT rs_ydelse.EOF)
%>
<option value=\"<%=(rs_ydelse.Fields.Item(\"ydelse\").Value)%>\" ><%=(rs_ydelse.Fields.Item(\"ydelse\").Value)%></option>
<%
rs_ydelse.MoveNext()
Wend
If (rs_ydelse.CursorType > 0) Then
rs_ydelse.MoveFirst
Else
rs_ydelse.Requery
End If
%>
<option value=\"<%=(rs_ydelse.Fields.Item(\"ydelse\").Value)%>\" selected><%=(rs_indhold.Fields.Item(\"ydelse\").Value)%></option>
</select>
</td>
</tr>
<tr valign=\"baseline\">
<td nowrap align=\"right\">Intgr:</td>
<td>
<select name=\"select3\">
<%
While (NOT rs_intgr.EOF)
%>
<option value=\"<%=(rs_intgr.Fields.Item(\"intgr\").Value)%>\" ><%=(rs_intgr.Fields.Item(\"intgr\").Value)%></option>
<%
rs_intgr.MoveNext()
Wend
If (rs_intgr.CursorType > 0) Then
rs_intgr.MoveFirst
Else
rs_intgr.Requery
End If
%>
<option value=\"<%=(rs_intgr.Fields.Item(\"intgr\").Value)%>\" selected><%=(rs_indhold.Fields.Item(\"intgr\").Value)%></option>
</select>
</td>
</tr>
<tr valign=\"baseline\">
<td nowrap align=\"right\">Overskrift:</td>
<td>
<input type=\"text\" name=\"overskrift\" value=\"<%=(rs_indhold.Fields.Item(\"overskrift\").Value)%>\" size=\"32\">
</td>
</tr>
<tr valign=\"baseline\">
<td nowrap align=\"right\">Kort_beskrivelse:</td>
<td>
<input type=\"text\" name=\"kort_beskrivelse\" value=\"<%=(rs_indhold.Fields.Item(\"kort_beskrivelse\").Value)%>\" size=\"32\">
</td>
</tr>
<tr valign=\"baseline\">
<td nowrap align=\"right\">Lang_beskrivelse:</td>
<td>
<input type=\"text\" name=\"lang_beskrivelse\" value=\"<%=(rs_indhold.Fields.Item(\"lang_beskrivelse\").Value)%>\" size=\"32\">
</td>
</tr>
<tr valign=\"baseline\">
<td nowrap align=\"right\">Links:</td>
<td>
<input type=\"text\" name=\"links\" value=\"<%=(rs_indhold.Fields.Item(\"links\").Value)%>\" size=\"32\">
</td>
</tr>
<tr valign=\"baseline\">
<td nowrap align=\"right\">Gfx:</td>
<td>
<select name=\"select4\">
<%
While (NOT rs_gfx.EOF)
%>
<option value=\"<%=(rs_gfx.Fields.Item(\"gfx\").Value)%>\" ><%=(rs_gfx.Fields.Item(\"gfx\").Value)%></option>
<%
rs_gfx.MoveNext()
Wend
If (rs_gfx.CursorType > 0) Then
rs_gfx.MoveFirst
Else
rs_gfx.Requery
End If
%>
<option value=\"<%=(rs_gfx.Fields.Item(\"gfx\").Value)%>\" selected><%=(rs_indhold.Fields.Item(\"gfx\").Value)%></option>
</select>
</td>
</tr>
<tr valign=\"baseline\">
<td nowrap align=\"right\"> </td>
<td>
<input type=\"submit\" value=\"Update Record\">
</td>
</tr>
</table>
<input type=\"hidden\" name=\"MM_update\" value=\"true\">
<input type=\"hidden\" name=\"MM_recordId\" value=\"<%= rs_indhold.Fields.Item(\"id\").Value %>\">
</form>
<p> </p>
<form name=\"form1\">
</form>
<p> </p>
</body>
</html>
<%
rs_indhold.Close()
%>
<%
rs_teknologi.Close()
%>
<%
rs_ydelse.Close()
%>
<%
rs_intgr.Close()
%>
<%
rs_gfx.Close()
%>
