janrussell
IS-IT--Management
Maybe I'm just burned out on this, but I can't seem to catch an update error - at least there should be an error. I am trying to read in Excel data and update a SQL table with the values from Excel. That all works fine. But what I want to do is flag an entry in the Excel spreadsheet by writing to a specific cell if the update didn't occur for that element (i.e., the project code did not exist). The SQL is:
Call Db.Execute("Update PROJECT set user_cost1 = '" & ProjTotal1 & "', user_cost2 = '" & ProjTotal2 & "', user_text5 = '" & Monthtag & "', user_cost3 = '" & ProjTotal3 & "' where proj_short_name = '" & ProjCodeName & " '"
I have a ProjCodeName value in the Excel spreadsheet that doesn't exist in the SQL table. How do I catch the fact that it didn't find a particular value so the update failed? I've tried using ON ERROR and other variations to trap something....
Please can anyone tell me what to do? The following code snippet is my latest attempt
Call Db.Execute("Update PROJECT set user_cost1 = '" & ProjTotal1 & "', user_cost2 = '" & ProjTotal2 & "', user_text5 = '" & Monthtag & "', user_cost3 = '" & ProjTotal3 & "' where proj_short_name = '" & ProjCodeName & " '"
MyConErr = Err.Number
If (MyConErr <> 0) Then
MsgBox ("Update error. Review spreadsheet for failed record."
myxlsheet.Cells(iRow, 5).Value = "**"
Err.Clear
End If
Thanks!
Call Db.Execute("Update PROJECT set user_cost1 = '" & ProjTotal1 & "', user_cost2 = '" & ProjTotal2 & "', user_text5 = '" & Monthtag & "', user_cost3 = '" & ProjTotal3 & "' where proj_short_name = '" & ProjCodeName & " '"
I have a ProjCodeName value in the Excel spreadsheet that doesn't exist in the SQL table. How do I catch the fact that it didn't find a particular value so the update failed? I've tried using ON ERROR and other variations to trap something....
Please can anyone tell me what to do? The following code snippet is my latest attempt
Call Db.Execute("Update PROJECT set user_cost1 = '" & ProjTotal1 & "', user_cost2 = '" & ProjTotal2 & "', user_text5 = '" & Monthtag & "', user_cost3 = '" & ProjTotal3 & "' where proj_short_name = '" & ProjCodeName & " '"
MyConErr = Err.Number
If (MyConErr <> 0) Then
MsgBox ("Update error. Review spreadsheet for failed record."
myxlsheet.Cells(iRow, 5).Value = "**"
Err.Clear
End If
Thanks!