Does ADO return a Return Code from .Execute

Posted on 2007-10-18
Medium Priority
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
  • 2
LVL 25

Accepted Solution

SStory earned 1600 total points
ID: 20100294
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)

Author Comment

ID: 20100512

Thanks for the info, this should help.

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

LVL 143

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 400 total points
ID: 20100924
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.

Author Comment

ID: 20101364
Thanks for the info guys!

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

862 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