Today is one of those days were you're gonna think, that can't possibly be real ... no seriously ... it can't be! But it is; Chris F sure can attest to that. He found this while investigating connection pool exhaustion problems in an application he was unfortunate enough to inherit. The author, apparently, thought that converting a string (that oddly resembles valid code) to an integer would magically find the execution context and perform these calls on the appropriate objects. Worse still, it's only the tip of the iceberg ...

Public Function CloseConnection(ByVal connectionNum As Integer) As Integer
  On Error Resume Next
  Dim ReturnStatus As Integer
  ReturnStatus = "sqlConnection" & CStr(connectionNum) & ".Close()"

  If ReturnStatus <> 0 Then
    Return False
  End If

  Return True
  Exit Function
End Function

[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!