Return Code From SQL Executions

G

Guest

As a mainframer, I used the DB2 return code to determine whether a read, an
update or an insert was successful, a duplicate, not found, etc. I am trying
to find a usable return code from SQL Server accessed from VBA with SQL
statements executed therein. I have searched books on SQL Server 7 and 2000
in vain. Can anyone help?
Earl Phillips
Volunteer Programmer
Harvesters Community Food Bank
 
R

RoyVidar

EarlCPhillips said:
As a mainframer, I used the DB2 return code to determine whether a
read, an update or an insert was successful, a duplicate, not found,
etc. I am trying to find a usable return code from SQL Server
accessed from VBA with SQL statements executed therein. I have
searched books on SQL Server 7 and 2000 in vain. Can anyone help?
Earl Phillips
Volunteer Programmer
Harvesters Community Food Bank

It's a bit dependent on how you "fire off" your SQL. If you use stored
procedures etc, you could use an output parameter - but then you'll
need
the ADO command object, i think.

For "usual" execution, both the DAO and ADO .execute methods support
"recordsaffected".

dim db as dao.database
set db=currentdb
db.execute "<some sql>", dbfailonerror
msgbox db.recordsaffected

dim cn as adodb.connection
dim lngRecAff as long
set db=currentproject.connection
cn.execute "<some sql>", lngRecAff, adCmdText + adExecuteNoRecords
msgbox lngRecAff
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top