Does ADO return a Return Code from .Execute

Posted on 2007-10-18
Last Modified: 2013-12-25

I am inserting rows into a MySQL DB from VB6 using ADO and was wondering if the .Execute method returns a Return Code after execution.  Here are my code snippets:

Dim MySQLConn As New ADODB.Connection
wTestName = txtTestName.Text
InsertString = "Insert into ProductCert.tests (test_name) value ('" & wTestName & "')"

Can I code the .Execute as such:
rc = MySQLConn.Execute(InsertString)
and expect a RC to be returned?  If so, what should the data type of rc be?

Question by:abrusko
    LVL 25

    Accepted Solution

    The Execute method returns a Recordset object.  There is an optional second parameter (a long) that can be passed in (by reference) to be set to how many records the query affected.

    to catch errors, place an On Error Goto, before you execute.

    Inside the error handling code, you can acess
    MYSQLConn.Errors (an error collection)
    LVL 3

    Author Comment


    Thanks for the info, this should help.

    Just curious...what is returned in the recordset object on an Insert or Update SQL statement?

    LVL 142

    Assisted Solution

    by:Guy Hengel [angelIII / a3]
    on insert/update/delete, the execute does returns a closed recordset eventually, or rather nothing.
    only during select, and eventually during a execute procedure, in case those have selects.
    LVL 3

    Author Comment

    Thanks for the info guys!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
    I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
    Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now