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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADO equivalent to CurrentDb.Execute 1

Status
Not open for further replies.

RobertT687

Programmer
Apr 2, 2001
425
US
I'm in the process of teaching myself to use ADO rather than DAO when developing new Access2K databases. I'm comfortable with using connections, recordsets etc. What I can't seem to find is an example of ADO code that replaces the simple DAO command CurrentDB.Execute(sql action code here).
The DAO command avoids the necessity of creating a recordset to do a simple UPDATE or DELETE (i.e. CurrentDb.Execute("DELETE * FROM [mytable]") where '[mytable]' is a local table to the database or a linked ODBC table.

I like the simplicity of the DAO command and want to know if there is as simple a method available to ADO.

PS for the sake of argument, assume the DAO libraries are not used.

Thanks in advance.
 
It's very easy, and the command object will return the number of records affected, which is very useful.

[tt]
Dim CNN As ADODB.Connection
Dim lngRecordsAffected as Long
Dim strSQL as String
Set CNN = CurrentProject.Connection
CNN.Execute strSQL, lngRecordsAffected, adCmdText
[/tt]

Jeffrey R. Roberts
Insight Data Consulting
Access, SQL Server, & Oracle Development
 
Hi RobertT687,

I'm no ADO expert but isn't it just Connection.Execute?

Enjoy,
Tony

------------------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading FAQ222-2244 before you ask a question.
 
That's the best, simplest example I've seen to date.

Thanks! You get a star!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top