Ok, I'm back again. I'm running into this problem. I am trying to catch errors when inserting records into a table. No problems if they are non-existant, but if the record already exists, I get a "cannot insert duplicate key in object". I am a DBA, so I am forcing this error and trying to get my script to write the error to the log file and continue processing rest of the inserts I need to do. The problem is, my error handling is not working.
Could someone point out what I am doing wrong or how to fix it?
Thanks :-(
If Err.number <> 0 Then
LogFile.WriteLine("Error Adding user" & strUserName & " for group " & _
strUserGroup & vbCRLF & vbTab & _
"Description: " & err.Descripion & vbCRLF & vbTab & _
"Error Number: " & err.Number & vbCRLF & vbTab & _
"SQL State: " & err.SQLState)
Else
LogFile.WriteLine(DateToday & " " & Time & vbTab & "Successful add of " & strUserName & _
" for group " & strUserGroup)
End If
Could someone point out what I am doing wrong or how to fix it?
Thanks :-(
If Err.number <> 0 Then
LogFile.WriteLine("Error Adding user" & strUserName & " for group " & _
strUserGroup & vbCRLF & vbTab & _
"Description: " & err.Descripion & vbCRLF & vbTab & _
"Error Number: " & err.Number & vbCRLF & vbTab & _
"SQL State: " & err.SQLState)
Else
LogFile.WriteLine(DateToday & " " & Time & vbTab & "Successful add of " & strUserName & _
" for group " & strUserGroup)
End If