If you do not want to check for errors, you can:
cmd.CommandText = "insert into MyTable values(blah, blah, blah) SELECT @@Rowcount" cmd.CommandType = adCmdText Set rs = cmd.Execute() RecordsAffected = rs(0)
In the same law, if you have an identifier column, you can get the identifier obtained using
cmd.CommandText = "insert into MyTable values(blah, blah, blah) SELECT @@Identity" cmd.CommandType = adCmdText Set rs = cmd.Execute() NewID = rs(0)
source share