Is gelukt :-D.
En heb hem de naam Invoer gegegeven!.
Maar nu kom ik direct met nog een probleempje, weet niet of ik dat hier ook mag vragen of dat ik beter een nieuwe topic moet openen. Maar misschien weten jullie het wel en mag het in deze topic
Ik wil dus dat formulier ook correct locken, dus op het moment dat ik melding 617 selecteer wil ik eigenlijk dat er een slot komt op deze record, zodat alleen die client die dat heeft opgevraagt deze mag editen, de andere clients mogen alle records zien en edit behalve deze!
Nu gebruikte ik hiervoor eerst locktype.readonly maar dan kan maar 1 persoon tegelijk editen.
Met adLockPessimistic hoopte ik dit te kunnen bereiken, maar dat werkt ook niet. De verschillende clients kunnen elkaars gegevens overschrijven.
Ik vermoedt dat het te maken heeft met de momenten waarop ik de recordset open en sluit, denk dat het hiermee mis gaat maar weet niet goed welke regels hiervoor zijn. Of Op welke manier je moet open en sluiten zodat dit netjes gebeurd. Dus zo minmogelijk onodige locks.
ik gebruik de volgende 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
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
| <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
.style1 {
font-size: xx-large;
font-weight: bold;
}
.style4 {font-family: Arial, Helvetica, sans-serif; font-weight: bold; }
body {
}
-->
</style>
<%
Dim Rs
Set Rs = Server.CreateObject("ADODB.Recordset")
With Rs
.CursorType = 3
.LockType = 3
End With
Dim Rs2
Set Rs2 = Server.CreateObject("ADODB.Recordset")
With Rs2
.CursorType = 3
.LockType = 2
End With
Dim buitvoeren
buitvoeren = False
Set db=Server.CreateObject("ADODB.connection")
path=server.MapPath("DataStore.mdb")
driver="provider=Microsoft.Jet.OLEDB.4.0;"
strcon=driver & ";Data Source="& path &";User id=admin;Password=;"
db.Open(strcon)%>
<%
sub Opslaan()
if request.form("ID")<>"" then
sql = "Select * FROM TBLGEGEVENS WHERE ID ="&request.Form("ID")&";"
else
sql ="Select * FROM TBLGEGEVENS WHERE ID =617;"
end if
call Rs2.open(sql,db)
if Request.Form("invoer") = "Opslaan" then
''updateQuery ="UPDATE TBLGEGEVENS SET Datum=#"& request.form("Datum")& "#, Gap ='"&request.Form("Gap")&"' , Shift ='"& request.form("Shift")& "', Naam ='"&request.form("Naam")&"', Huidige_situatie ='" & Request.Form("Huidige_situatie")&"' WHERE ID=" & request.form("ID") & ";"
Rs2.Close
call Rs2.open(sql,db)
Rs2("Datum")= request.Form("Datum")
Rs2("Gap")= request.Form("Gap")
Rs2("Shift")= request.Form("Shift")
Rs2("Naam")=Request.Form("Naam")
Rs2("Huidige_situatie")= request.Form("Huidige_situatie")
Rs2("Oplossing")= request.Form("Oplossing")
Rs2("Opmerking")= request.Form("Opmerking")
Rs2("Resp")= request.Form("Resp")
Rs2("Onderwerp")= request.Form("Onderwerp")
Rs2("Status")= request.Form("Status")
Rs2.Update
Rs2.Close
else
Response.Write("Dacht het niet he")
end if
end sub%>
</head>
<body>
<p class="style1">Idee Wijzige</p>
<hr noshade>
<form name="form1" method="post" action="">
<table width="904" border="0">
<tr>
<td width="122" height="38" class="style4">ID</td>
<td width="20"> </td>
<td width="144">
<select name="ID" onChange="document.form1.submit();">
<%sql="SELECT DISTINCT ID FROM TBLGEGEVENS WHERE ID LIKE '%';"
call Rs.open(sql,db) %>
<%do while not Rs.eof %>
<option selected='selected'>
<%response.Write(Rs(0))%>
</option>
<%Rs.movenext
loop %>
<%Rs.Close%>
<% if request.form("ID")<>"" then sql="SELECT DISTINCT ID FROM TBLGEGEVENS WHERE ID LIKE '"& request.Form("ID") & "';" else sql="SELECT DISTINCT ID FROM TBLGEGEVENS;" end if%>
<%call Rs.open(sql,db) %>
<option selected='selected'><%response.Write(Rs(0))%></option>
<%Rs.close %>
</select></td>
<td width="85"> </td>
<td width="132"> </td>
<td width="48" rowspan="2"> </td>
<td width="62"><input type="submit" name="invoer" value="Opslaan" onClick="<% call Opslaan%>"></td>
<td width="49" rowspan="2"> </td>
<td width="44" rowspan="2"> </td>
<td width="44" rowspan="2"> </td>
<td width="44" rowspan="2"> </td>
<td width="60" rowspan="2"> </td>
</tr>
<tr>
<td><span class="style4">Datum</span></td>
<td width="20"> </td>
<td width="144">
<%if request.form("ID")<> "" then sql="SELECT DISTINCT DATUM FROM TBLGEGEVENS WHERE ID LIKE '"& request.Form("ID") & "';" else sql="SELECT DISTINCT DATUM FROM TBLGEGEVENS;" end if%>
<%call Rs.open(sql,db) %>
<input name="Datum" type="text" id="Datum" value=<%response.Write(Rs(0))%>>
</input>
<% Rs.close%></td>
<td width="85"><span class="style4">Shift</span></td>
<td width="132"> <select name="Shift" id="Shift">
<option>A</option>
<option>B</option>
<option>C </option>
<%if request.form("ID")<> "" then sql="SELECT DISTINCT Shift FROM TBLGEGEVENS WHERE ID LIKE '"& request.Form("ID") & "';" else sql="SELECT DISTINCT SHIFT FROM TBLGEGEVENS;" end if%>
<%call Rs.open(sql,db) %>
<option selected='selected'><%response.Write(Rs(0))%></option>
<%Rs.close %>
</select></td>
<td width="62"></td>
</tr>
<tr>
<td rowspan="2" class="style4">Gap
</td>
<td rowspan="2"> </td>
<td rowspan="2">
<select name="Gap" id="Gap">
<%sql="SELECT Gap FROM TBLGAP;" %>
<%call Rs.open(sql,db) %>
<%do while not Rs.eof %>
<option>
<%response.Write(Rs(0))%>
</option>
<%Rs.movenext
loop %>
<%Rs.close%>
<% if request.form("ID")<>"" then sql="SELECT DISTINCT GAP FROM TBLGEGEVENS WHERE ID LIKE '"& request.Form("ID") & "';" else sql="SELECT DISTINCT GAP FROM TBLGEGEVENS;" end if%>
<%call Rs.open(sql,db) %>
<option selected='selected'><%response.Write(Rs(0))%></option>
<%Rs.close %>
</select></td>
<td rowspan="2"><span class="style4">Naam</span></td>
<td rowspan="2">
<select name="Naam" id="Naam">
<%sql="SELECT Naam FROM TBLNAAM;" %>
<%call Rs.open(sql,db) %>
<%do while not Rs.eof %>
<option>
<%response.Write(Rs(0))%>
</option>
<%Rs.movenext
loop %>
<%Rs.close%>
<% if request.form("ID")<>"" then sql="SELECT DISTINCT Naam FROM TBLGEGEVENS WHERE ID LIKE '"& request.Form("ID") & "';" else sql="SELECT DISTINCT Naam FROM TBLNAAM;" end if%>
<%call Rs.open(sql,db) %>
<option selected='selected'><%response.Write(Rs(0))%></option>
<%Rs.close %>
</select></td>
<td rowspan="2"> </td>
<td rowspan="2"> </td>
<td rowspan="2"> </td>
<td rowspan="2"> </td>
<td rowspan="2"> </td>
<td rowspan="2"> </td>
<td rowspan="2"> </td>
</tr>
<tr> </tr>
<tr>
<td><span class="style4">Huidige Situatie </span></td>
<td> </td>
<td colspan="3"><textarea name="Huidige_situatie" cols="55" rows="5" id="Huidige_situatie"><% if request.form("ID")<>"" then sql="SELECT DISTINCT Huidige_Situatie FROM TBLGEGEVENS WHERE ID LIKE '"& request.Form("ID") & "';" else sql="SELECT DISTINCT Huidige_Situatie FROM TBLGEGEVENS;" end if%>
<%call Rs.open(sql,db) %>
<%response.Write(Rs(0))%>
<%Rs.close %></textarea></td>
<td> </td>
</tr>
<tr>
<td><span class="style4">Oplossing</span></td>
<td> </td>
<td colspan="3"><textarea name="Oplossing" cols="55" rows="5" id="Oplossing"><% if request.form("ID")<>"" then sql="SELECT Oplossing FROM TBLGEGEVENS WHERE ID Like '"& request.Form("ID") & "';" else sql="SELECT Oplossing FROM TBLGEGEVENS WHERE ID Like'%';" end if%>
<%call Rs.open(sql,db) %><%response.Write(Rs(0))%><%Rs.close%>
</textarea></td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td><span class="style4">Opmerking</span></td>
<td> </td>
<td colspan="3"><textarea name="Opmerking" cols="55" rows="5" id="Opmerking"><% if request.form("ID")<>"" then sql="SELECT Opmerking FROM TBLGEGEVENS WHERE ID Like '"& request.Form("ID") & "';" else sql="SELECT Opmerking FROM TBLGEGEVENS WHERE ID Like'%';" end if%>
<%call Rs.open(sql,db) %><%response.Write(Rs(0))%><%Rs.close%>
</textarea></td>
<td> </td>
</tr>
<tr>
<td><span class="style4">Responsible</span></td>
<td> </td>
<td><select name="Resp" id="Resp">
<%sql="SELECT Resp FROM TBLResp;" %>
<%call Rs.open(sql,db) %>
<%do while not Rs.eof %>
<option>
<%response.Write(Rs(0))%>
</option>
<%Rs.movenext
loop %>
<%Rs.close%>
<% if request.form("ID")<>"" then sql="SELECT DISTINCT Resp FROM TBLGEGEVENS WHERE ID LIKE '"& request.Form("ID") & "';" else sql="SELECT DISTINCT Resp FROM TBLResp;" end if%>
<%call Rs.open(sql,db) %>
<option selected='selected'><%response.Write(Rs(0))%></option>
<%Rs.close %>
</select></td>
<td><span class="style4">Onderwerp</span></td>
<td><select name="Onderwerp" id="Onderwerp">
<%sql="SELECT Onderwerp FROM TBLONDERWERP;" %>
<%call Rs.open(sql,db) %>
<%do while not Rs.eof %>
<option>
<%response.Write(Rs(0))%>
</option>
<%Rs.movenext
loop %>
<%Rs.close%>
<% if request.form("ID")<>"" then sql="SELECT DISTINCT ONDERWERP FROM TBLGEGEVENS WHERE ID LIKE '"& request.Form("ID") & "';" else sql="SELECT DISTINCT ONDERWERP FROM TBLONDERWERP;" end if%>
<%call Rs.open(sql,db) %>
<option selected='selected'><%response.Write(Rs(0))%></option>
<%Rs.close %>
</select></td>
<td> </td>
</tr>
<tr>
<td><span class="style4">Status</span></td>
<td> </td>
<td colspan="3"><select name="status" id="status">
<%sql="SELECT Status FROM TBLSTATUS;" %>
<%call Rs.open(sql,db) %>
<%do while not Rs.eof %>
<option>
<%response.Write(Rs(0))%>
</option>
<%Rs.movenext
loop %>
<%Rs.close%>
<% if request.form("ID")<>"" then sql="SELECT DISTINCT Status FROM TBLGEGEVENS WHERE ID LIKE '"& request.Form("ID") & "';" else sql="SELECT DISTINCT Status FROM TBLSTATUS;" end if%>
<%call Rs.open(sql,db) %>
<option selected='selected'><%response.Write(Rs(0))%></option>
<%Rs.close %>
</select></td>
</tr>
</table>
</form>
<p> </p>
</body>
</html> |
Wat zijn nu de ideale momenten om een lock aan te vragen en vrij te geven. Ik gebruik voor de update een recordset met de naam Rs2 omdat ik dacht dat dat misschien handig is om een aparte lock te verkrijgen gedeurende de volledige update. Maar via Rs wel nog andere gegevens kan opvragen.
Heeft iemand misschien een goed voorbeeld of een link naar een site waarin ze dit probleem behandelen