jack niekerk
asked on
SMARTER WAY TO UPDATE RECORDS IN ADOSETS
'this is what I do
Private Sub sftBegin_LostFocus()
Dim rsbrokers As New ADODB.Recordset
rsbrokers.CursorLocation = adUseServer
rsbrokers.Open "brookers", "provider=PervasiveOLEDB;D ata source=Newindia", adOpenDynamic, adLockOptimistic, adCmdTableDirect
rsbrokers.MoveFirst
'I sroll in grid, and because txtBrokerid is bound to datasource
' it will contain the recordid, e.g JACK01 when I click in sftBegin
' now below works, but; is ok when file has e.g. 150 records, and will be to slow if we goto 2500 'records, so the question is, after picking a line from the ADO recordset/grid and coming in this
sub knowing only the key wich belongs to this record, finding a fast way to put the index right away
'to the correct recordset and only do a update!
While rsbrokers.Fields(0) <> txtBrokerId
rsbrokers.MoveNext
Wend
rsBrokers.Fields("Brokerna me") = sftBegin.text
rsbrokers.update
End Sub
Regards Jack
Private Sub sftBegin_LostFocus()
Dim rsbrokers As New ADODB.Recordset
rsbrokers.CursorLocation = adUseServer
rsbrokers.Open "brookers", "provider=PervasiveOLEDB;D
rsbrokers.MoveFirst
'I sroll in grid, and because txtBrokerid is bound to datasource
' it will contain the recordid, e.g JACK01 when I click in sftBegin
' now below works, but; is ok when file has e.g. 150 records, and will be to slow if we goto 2500 'records, so the question is, after picking a line from the ADO recordset/grid and coming in this
sub knowing only the key wich belongs to this record, finding a fast way to put the index right away
'to the correct recordset and only do a update!
While rsbrokers.Fields(0) <> txtBrokerId
rsbrokers.MoveNext
Wend
rsBrokers.Fields("Brokerna
rsbrokers.update
End Sub
Regards Jack
ASKER
OK, this is what I do
but: during run-time I get error while conn.Open "bro.................
is blue at: .Open position with error text: wrong numbers of arguments or invalid property assigment.
what did I do wrong??
Thank you,
Jack
Private Sub cmdtest_Click()
Dim conn As New ADODb.Connection
Dim rsBrokers As New ADODb.Recordset
' it gets blue with error below, at pos. .OPEN "br......
conn.Open "brookers", "provider=PervasiveOLEDB;D ata source=Newindia", adOpenDynamic, adLockOptimistic, adCmdTableDirect
res.Open "update brookers set BROKERNAME1= " + txtName1 _ + ",BROKERSTREET1=" + txtStreet1 + ", BROKERCITY1=" + txtCity1 + " WHERE FIRSTFIELD =" + txtBrokerId, conn
Close rsBrokers
End Sub
but: during run-time I get error while conn.Open "bro.................
is blue at: .Open position with error text: wrong numbers of arguments or invalid property assigment.
what did I do wrong??
Thank you,
Jack
Private Sub cmdtest_Click()
Dim conn As New ADODb.Connection
Dim rsBrokers As New ADODb.Recordset
' it gets blue with error below, at pos. .OPEN "br......
conn.Open "brookers", "provider=PervasiveOLEDB;D
res.Open "update brookers set BROKERNAME1= " + txtName1 _ + ",BROKERSTREET1=" + txtStreet1 + ", BROKERCITY1=" + txtCity1 + " WHERE FIRSTFIELD =" + txtBrokerId, conn
Close rsBrokers
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
if you like to use sql you could just execute a code like this..
-------------------------
dim conn as new Adodb.connection
dim res as new Adodb.recordset
'other codes
conn.Open "Provider=Microsoft.Jet.Ol
'other codes
res.Open "update YOURTABLE set BROKERNAME = '" & SFTBEGIN.TEXT & "', FIELD2 = " & TXTNUM.TEXT & ", FIELD3 = #" & TXTDATE.TEXT & "# where FIRSTFIELD = " & TXTBROKERID, conn
'other codes
something like that.. then close res..
the code would look for txtbrokerid in the firstfield and update yourtable with a new brokername...