Not all chemicals are bad. Without hydrogen or oxygen, for example, there would be no way to make water, a vital ingredient in beer.
Verwijderd
--> zet de code wel ff om naar ASP/VB door (create object)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
| 'maak een nieuwe instance van je recordset
dim objRs As ADODB.Recordset
objRs.Cursorlocation = adUseClient
'haal alle records op
objRs.Open "SELECT * FROM jouwTabel", _
"Provider=SQLOLEDB;Initial Catalog=jouwDatabase; " _
"Data Source=jouwServer;User=jouwUser;Password=jouwPassword; ", _
"adOpenStatic, adLockBatchOptimistic
Set objRs.ActiveConnection = Nothing
'pas hier je records aan!
objRs("blaat") = "blaat2"
'connect opnieuw
objRs.ActiveConnection = "Provider=SQLOLEDB;Initial Catalog=jouwDatabase; " _
"Data Source=jouwServer;User=jouwUser;Password=jouwPassword; "
'update de tabel
objRs.UpdateBatch
'vernietig objecten
Set objRs = Nothing |
That's it
[ Voor 28% gewijzigd door Verwijderd op 02-02-2004 21:20 ]
Key column information is insufficient or incorrect. Too many rows were affected by update.
Het gaat echter maar om 7 rijen. Tevens lijkt het me ietwat omslachtig om de activeconnection op nothing te zetten om vervolgens weer terug te zetten. Dit kan vast anders?
Not all chemicals are bad. Without hydrogen or oxygen, for example, there would be no way to make water, a vital ingredient in beer.
Verwijderd
EDIT:: je zet alleen de active connection op je recordset op nothing hoor
BTW als je niet ALLE records wilt updaten, zet dan ff de MarshalOptions op AdMarshalModifiedOnly.....dan zullen alleen de aangepaste records worden teruggestuurd
[ Voor 80% gewijzigd door Verwijderd op 02-02-2004 21:36 ]
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
| 'Cursortypes
Const adOpenDynamic = 2, adOpenForwardOnly = 0, adOpenKeyset = 1, adOpenStatic = 3
'Locktypes
Const adLockBatchOptimistic = 4, adLockOptimistic = 3, adLockPessimistic = 2, adLockReadOnly = 1
Const adUseClient = 3
Set con = Server.CreateObject("ADODB.Connection")
con.Open DSN
Set rsBetalingen = Server.CreateObject("ADODB.Recordset")
rsBetalingen.Cursorlocation = adUseClient
rsBetalingen.Open "SELECT rekeningnummer, aantaladressen, verwerkt FROM Klant WHERE gecompleteerd AND NOT verwerkt", con, adOpenStatic, adLockBatchOptimistic
rsBetalingen.ActiveConnection = Nothing
If Not rsBetalingen.eof Then
'Blablabla
Do Until rsBetalingen.eof
rsBetalingen.Fields("verwerkt").Value = 1
rsBetalingen.MoveNext
Loop
rsBetalingen.ActiveConnection = DSN
rsBetalingen.UpdateBatch
End If
rsBetalingen.Close
Set rsBetalingen = Nothing
con.Close
Set con = Nothing |
DSN is in dit geval de connectiestring, rest staat erbij volgens mij.
Edit:
Het valt me op dat ie de records wel bijwerkt ondanks de foutmelding. Als ik de regel met updatebatch uitzet doet ie dit niet. Verschil tussen activeconnection tussentijds op nothing zetten en dat niet doen zie ik niet.
[ Voor 14% gewijzigd door Nutcaze op 02-02-2004 21:44 ]
Not all chemicals are bad. Without hydrogen or oxygen, for example, there would be no way to make water, a vital ingredient in beer.
Verwijderd
Verder zou ik alles in subs gooien en dan op de diverse plaatsen de subs aanspreken (voorbeeld zien?)....ik heb het al helemaal aangepast
ik doe hieronder ff een voorbeeld van updateBatch uit msdn;
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
| Public Sub UpdateBatchX()
Dim rstTitles As ADODB.Recordset
Dim strCnn As String
Dim strTitle As String
Dim strMessage As String
' Assign connection string to variable.
strCnn = "Provider=sqloledb;" & _
"Data Source=srv;Initial Catalog=pubs;User Id=sa;Password=; "
Set rstTitles = New ADODB.Recordset
rstTitles.CursorType = adOpenKeyset
rstTitles.LockType = adLockBatchOptimistic
rstTitles.Open "titles", strCnn, , , adCmdTable
rstTitles.MoveFirst
' Loop through recordset and ask user if she wants
' to change the type for a specified title.
Do Until rstTitles.EOF
If Trim(rstTitles!Type) = "psychology" Then
strTitle = rstTitles!Title
strMessage = "Title: " & strTitle & vbCr & _
"Change type to self help?"
If MsgBox(strMessage, vbYesNo) = vbYes Then
rstTitles!Type = "self_help"
End If
End If
rstTitles.MoveNext
Loop
' Ask if the user wants to commit to all the
' changes made above.
If MsgBox("Save all changes?", vbYesNo) = vbYes Then
rstTitles.UpdateBatch
Else
rstTitles.CancelBatch
End If
' Print current data in recordset.
rstTitles.Requery
rstTitles.MoveFirst
Do While Not rstTitles.EOF
Debug.Print rstTitles!Title & " - " & rstTitles!Type
rstTitles.MoveNext
Loop
' Restore original values because this is a demonstration.
rstTitles.MoveFirst
Do Until rstTitles.EOF
If Trim(rstTitles!Type) = "self_help" Then
rstTitles!Type = "psychology"
End If
rstTitles.MoveNext
Loop
rstTitles.UpdateBatch
rstTitles.Close
End Sub |
EDIT:: het gekke is dat zij hier ook niet de connectie op nothing zetten terwijl dit echt wel de bedoeling is vlgs mij
[ Voor 9% gewijzigd door Verwijderd op 02-02-2004 22:05 ]
Anyway hij doet het nu zonder dat de activeconnection op nothing gezet wordt tussentijds. Thanks.
Not all chemicals are bad. Without hydrogen or oxygen, for example, there would be no way to make water, a vital ingredient in beer.
Verwijderd
Perfecto!!! problem fixed hehehe......Nutcaze schreef op 02 februari 2004 @ 22:09:
Ik heb 'm zojuist gevonden, het antwoord zat al verscholen in de foutmelding. Ik had in de query geen unieke index opgenomen. Hier had ie kennelijk problemen mee. Hoewel wel de juiste rijen ge-update werden. Misschien komt dit doordat alle rijen uit de recordset worden ge-update. Who knows?
Anyway hij doet het nu zonder dat de activeconnection op nothing gezet wordt tussentijds. Thanks.
Not all chemicals are bad. Without hydrogen or oxygen, for example, there would be no way to make water, a vital ingredient in beer.
Verwijderd
Not all chemicals are bad. Without hydrogen or oxygen, for example, there would be no way to make water, a vital ingredient in beer.
Not all chemicals are bad. Without hydrogen or oxygen, for example, there would be no way to make water, a vital ingredient in beer.
Verwijderd
Ga je nuttig om met je objecten dan kan dat heel wat snelheidswinst opleveren (en bijkomend voordeel voor de provider = minder belasting)