Warning: ASP n00b!
Ik ben sinds een week bezig met ASP (gebruik DreamWeaver MX), maar nu krijg ik de Insert Record maar niet aan de praat. En uit de Search & tutorials wordt ik ook niet wijzer.
De error is de volgende:
En hier is de ASP pagina waar het om gaat. Een hele hoop onoverzichtelijke Dreamweaver code inderdaad, maar zonder DW lukt het me nog niet.
Regels 110 tot 116:
Maar de fout zit denk ik eerder, 115 is alleen de regel die het daadwerkelijk uitvoerd..
Daarom hieronder de hele code:
Ik ben sinds een week bezig met ASP (gebruik DreamWeaver MX), maar nu krijg ik de Insert Record maar niet aan de praat. En uit de Search & tutorials wordt ik ook niet wijzer.
code:
1
2
3
4
| Error Type: Microsoft OLE DB Provider for ODBC Drivers (0x80004005) [Microsoft][ODBC Microsoft Access Driver] Operation must use an updateable query. /adminDivx.asp, line 115 |
En hier is de ASP pagina waar het om gaat. Een hele hoop onoverzichtelijke Dreamweaver code inderdaad, maar zonder DW lukt het me nog niet.
Regels 110 tot 116:
code:
1
2
3
4
5
6
7
| If (Not MM_abortEdit) Then
' execute the insert
Set MM_editCmd = Server.CreateObject("ADODB.Command")
MM_editCmd.ActiveConnection = MM_editConnection
MM_editCmd.CommandText = MM_editQuery
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close |
Maar de fout zit denk ik eerder, 115 is alleen de regel die het daadwerkelijk uitvoerd..
Daarom hieronder de hele code:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
| <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/divx.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 & "?" & Request.QueryString
End If
' boolean to abort record edit
MM_abortEdit = false
' query string to execute
MM_editQuery = ""
%>
<%
' *** Insert Record: set variables
If (CStr(Request("MM_insert")) = "addRecord") Then
MM_editConnection = MM_divx_STRING
MM_editTable = "titel"
MM_editRedirectUrl = "adminDivx.asp?errorMsg=Movie%20added"
MM_fieldsStr = "titel|value|mbs|value|formaat|value|genreLijst|value|opmerkingen|value|imdb url|value"
MM_columnsStr = "titel|',none,''|mbs|none,none,NULL|formaat|',none,''|genre|',none,''|opmerkingen|',none,''|[imdb url]|',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
%>
<%
' *** Insert Record: construct a sql insert statement and execute it
Dim MM_tableValues
Dim MM_dbValues
If (CStr(Request("MM_insert")) <> "") Then
' create the sql insert statement
MM_tableValues = ""
MM_dbValues = ""
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_tableValues = MM_tableValues & ","
MM_dbValues = MM_dbValues & ","
End If
MM_tableValues = MM_tableValues & MM_columns(MM_i)
MM_dbValues = MM_dbValues & MM_formVal
Next
MM_editQuery = "insert into " & MM_editTable & " (" & MM_tableValues & ") values (" & MM_dbValues & ")"
If (Not MM_abortEdit) Then
' execute the insert
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 errorMsg
errorMsg = ""
If (Request.QueryString("errorMsg") <> "") Then
errorMsg = Request.QueryString("errorMsg")
End if
%>
<%
' *** Restrict Access To Page: Grant or deny access to this page
MM_authorizedUsers="admin"
MM_authFailedURL="divx.asp"
MM_grantAccess=false
If Session("MM_Username") <> "" Then
If (false Or CStr(Session("MM_UserAuthorization"))="") Or _
(InStr(1,MM_authorizedUsers,Session("MM_UserAuthorization"))>=1) Then
MM_grantAccess = true
End If
End If
If Not MM_grantAccess Then
MM_qsChar = "?"
If (InStr(1,MM_authFailedURL,"?") >= 1) Then MM_qsChar = "&"
MM_referrer = Request.ServerVariables("URL")
if (Len(Request.QueryString()) > 0) Then MM_referrer = MM_referrer & "?" & Request.QueryString()
MM_authFailedURL = MM_authFailedURL & MM_qsChar & "accessdenied=" & Server.URLEncode(MM_referrer)
Response.Redirect(MM_authFailedURL)
End If
%>
<%
Dim listAllTitle
Dim listAllTitle_numRows
Set listAllTitle = Server.CreateObject("ADODB.Recordset")
listAllTitle.ActiveConnection = MM_divx_STRING
listAllTitle.Source = "SELECT * FROM titel ORDER BY titel ASC"
listAllTitle.CursorType = 0
listAllTitle.CursorLocation = 2
listAllTitle.LockType = 1
listAllTitle.Open()
listAllTitle_numRows = 0
%>
<%
Dim listAllGenre
Dim listAllGenre_numRows
Set listAllGenre = Server.CreateObject("ADODB.Recordset")
listAllGenre.ActiveConnection = MM_divx_STRING
listAllGenre.Source = "SELECT * FROM genre ORDER BY genre ASC"
listAllGenre.CursorType = 0
listAllGenre.CursorLocation = 2
listAllGenre.LockType = 1
listAllGenre.Open()
listAllGenre_numRows = 0
%>
<html>
<head>
<title>lijst</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="divx.css">
</head>
<body>
<form action="" method="get" name="listMovies">
<select name="movieLijst" size="10" id="movieLijst">
<%
While (NOT listAllTitle.EOF)
%>
<option value="<%=(listAllTitle.Fields.Item("titel").Value)%>" <%If (Not isNull((listAllTitle.Fields.Item("titel").Value))) Then If (CStr(listAllTitle.Fields.Item("titel").Value) = CStr((listAllTitle.Fields.Item("titel").Value))) Then Response.Write("SELECTED") : Response.Write("")%> ><%=(listAllTitle.Fields.Item("titel").Value)%></option>
<%
listAllTitle.MoveNext()
Wend
If (listAllTitle.CursorType > 0) Then
listAllTitle.MoveFirst
Else
listAllTitle.Requery
End If
%>
</select>
<p>..</p></form>
<form ACTION="<%=MM_editAction%>" METHOD="POST" name="addRecord">
<table cellspacing="0" cellpadding="2">
<tr>
<td>Titel:</td>
<td><input type="text" name="titel"></td>
</tr>
<tr>
<td>MBs:</td>
<td><input type="text" name="mbs"></td>
</tr>
<tr>
<td>Formaat:</td>
<td><input type="text" name="formaat"></td>
</tr>
<tr>
<td>Genre:</td>
<td><select name="genreLijst" id="select">
<%
While (NOT listAllGenre.EOF)
%>
<option value="<%=(listAllGenre.Fields.Item("genre").Value)%>" <%If (Not isNull((listAllGenre.Fields.Item("genre").Value))) Then If (CStr(listAllGenre.Fields.Item("genre").Value) = CStr((listAllGenre.Fields.Item("genre").Value))) Then Response.Write("SELECTED") : Response.Write("")%> ><%=(listAllGenre.Fields.Item("genre").Value)%></option>
<%
listAllGenre.MoveNext()
Wend
If (listAllGenre.CursorType > 0) Then
listAllGenre.MoveFirst
Else
listAllGenre.Requery
End If
%>
</select></td>
</tr>
<tr>
<td>Opmerkingen:</td>
<td><input type="text" name="opmerkingen"></td>
</tr>
<tr>
<td>IMDB URL:</td>
<td><input type="text" name="imdb url"></td>
</tr>
<tr>
<td colspan="2" align="right">
<p><input type="submit" name="Submit" value="Add movie"></p></td></tr>
</table>
<input type="hidden" name="MM_insert" value="addRecord">
</form>
<p><%=Replace(errorMsg, "'", "''") %></p>
<p>User: <%=session("MM_Username")%><br>Status: <%=session("MM_UserAuthorization")%></p>
<p><a href="divx.asp">members Divx.asp</a><br>
<a href="divx2.asp">visitors Divx2.asp</a></p>
</body>
</html>
<%
listAllTitle.Close()
Set listAllTitle = Nothing
%>
<%
listAllGenre.Close()
Set listAllGenre = Nothing
%> |
“The best way to get the right answer on the Internet is not to ask a question, it's to post the wrong answer.”
QA Engineer walks into a bar. Orders a beer. Orders 0 beers. Orders 999999999 beers. Orders a lizard. Orders -1 beers.