The asset management application used Alex R.'s company isn't exactly bad, but sometimes it can be a little bit of a pain.

For example, some time ago, some deveoper implemented a feature that would check if the mainframe was up and running. This was done by simply querying a column in some database table. But shortly thereafter, users noticed that there was a brief pause after entering their password. Nothing earth shattering, it was just annoying.

When Alex heard someone mention the delay in passing, Alex figured it was probably some poorly implemented SQL to blame and volunteered to investigate what would likely amount to a quick fix. Alex tracked down the logic that checked if the mainframe was up and running. While the SQL wasn't fully to blame for the slowness, it certainly didn't help...

' Add column just in case it's not there
Try
    Dim sql As String = "ALTER TABLE [Mainframe] ADD MainframeOn Bit"
    If ExecuteNonQuery(sql) < 0 Then Exit Try

    Dim t As String = "0"
    If _Settings.GetSetting("General", "MainframeOn", False) Then t = "1"

    ExecuteNonQuery("UPDATE [dbo].[Mainframe] SET MainframeOn = " & t)
Catch
    ' Already run
End Try

MainframeOn = Utils.ConvertDBValue(Of Boolean) _
   (ExecuteScalar("SELECT TOP 1 [MainframeOn] FROM [dbo].[Mainframe]"), False)
[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!