Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to tell if a call to SQL Execute() using ADO fails in classic ASP

I have the following shortened classic ASP code that makes a SQL insert call...

cmd.CommandText = "insert into MyTable values(blah, blah, blah)"   
cmd.CommandType = adCmdText

Set rs = cmd.Execute()

Using the recordset that Execute() returns how can I tell whether the insertion was successful or not?

like image 733
Rob Segal Avatar asked Dec 22 '22 05:12

Rob Segal


1 Answers

Check the Err object

cmd.CommandText = "insert into MyTable values(blah, blah, blah)"   
cmd.CommandType = adCmdText
On Error Resume Next
Set rs = cmd.Execute()
If Err.number<>0 or  objConnection.Errors.Count <> 0 Then
   'Do something to handle the error
End If
On Error Goto 0

Also have a look at this link over at 15Seconds

like image 147
CResults Avatar answered Jan 13 '23 16:01

CResults