0

I'm running a few vb scripts on my QC server using the script editor. I'm using QC 12, i have a function that is establishing a connection using QC api, getting some data then incrementing this data by one, the thing is that it's getting an empty value from the DB. Here is the function:

Function SW_KeepTIDLastValue()
On Error Resume Next
  Dim tdc, val
  Dim cset
  Dim bld
  On Error Resume Next
  bld = ""
  Set tdc = TDConnection     'Open a connection using the QC API
  Set tdc =  CreateObject("TDApiOle80.TDConnection")
  Set cset = tdc.CommonSettings
  'Set cset = tdc.COMMON_SETTINGS
    cset.Open ("KeepTIDValueSetting")
    val = cset.Value("KeepTIDValueField")   'Retrieve the value stored in the DB
   ' val = CDbl(cset.Value("KeepTIDValueField"))
    msgbox(TypeName(val) & " " & val)
    SW_KeepTIDLastValue = val+1             'Increment the value by 1
    msgbox(TypeName(val) & " " & SW_KeepTIDLastValue )
    cset.Value("KeepTIDValueField") = val+1 'Store the value back in the DB
    cset.Close

If Err.Number <> 0 Then
  SW_DisplayError Err.Number, Err.Description, "Keep Last Value (" & action & ")"
End If

On Error GoTo 0

End Function
Alex Brodov
  • 3,365
  • 18
  • 43
  • 66
  • Get rid of your TWO `On Error Resume Next` statements and try your code again. It's going to be difficult to find the issue when you're purposefully hiding errors. – Bond Jul 21 '15 at 14:21
  • I've removed it, but it's not going through the function – Alex Brodov Jul 21 '15 at 15:19
  • Are you getting an error? – Bond Jul 21 '15 at 15:20
  • No, it's just not doing anything, i have a messageboxes for debugging, and they're not popping up – Alex Brodov Jul 21 '15 at 15:20
  • Where is this function called ? If the message boxes don't apper it is because your function is never called. Another problem is that you create tdconnection two times by using two different techniques. The second message box doesn't appear because you return to the function with this line of code "SW_KeepTIDLastValue = val+1 " – Benjamin BALET Aug 11 '15 at 08:51

0 Answers0