Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Edit Records using ADO 1

Status
Not open for further replies.

SpeakUp

MIS
Apr 1, 2002
19
0
0
PH
Hi!,
Just asking how to edit records using ADO, im really not much of an ADO user. This is my first time practicing ADO i know how to add records but not Edit and Delete. Im using ADO ODBC!!!
Any help!!! Pls.....
[pc]
 
Once you have the recordset in place, and assuming you have permissions to edit / delete...

recordset.fields("CustomerId").value = 1234
recordset.update

or

recordset!customerid = 1234
recordset.update

For deletion, recordset.delete

The delete method can accept an argument for affecting other records, so read up on that in MSDN.

The other thing you might want to read up on is executing SQL straight off the connection object, allowing you to use DELETE FROM and UPDATE.
 
Actually im using ADO ODBC but im not good in ADO. Can u give the equivalent code of this in ADO...

Set rs = db.OpenRecordset("MyTable", dbOpenDynaset)

With rs
.FindFirst "Field1='" & Text1 & "'"

If Not .NoMatch then
my code goes here .....
Else
No Data found in the Database
End if

End With
rs.Close
set rs = Nothing


I just want to know whats the equivalent of "NoMatch" in ADO? im using ADO ODBC... and i think there's no rs.Edit in ADO just an EditMode. I can now add but no edit yet...

Thnx!!!
Arnel
 
that's the code

Dim rs as adodb.recordset

set rs = New adodb.recordset
rs.open "MyTable", currentproject.connection, adOpenDynamic
with rs
'to test if there are any records
If Not .BOF then
'the following 2 lines are equivalend of the "FindFirst"
.MoveFirst
.Find "Field1='" & Text1 & "'"
'if the record doesn't exist, the pointer is at the end of the recordset
If Not .EOF then
my code goes here .....
Else
No Data found in the Database
End if
End If
End With
rs.Close
set rs = Nothing

Note that you have to insert the "Microsoft Active X Data Objects X.X Library"
 
I concur with MaxZak, and I'm giving the chap a star too!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top