title: SELECT SQL Statement not working as expected in VB.net Console application
body: <p>I know there are similar posts regarding this but i cant seem to find anything that works.</p>
  
  <p>I'm still new to VB and this which is probably obvious is driving me mad.</p>
  
  <p>What im looking to do is to Run a SQL SELECT and email the results to those who require it.</p>
  
  <p>When i run it I'm getting the 'ELSE' email which states that there is nothing on HOLD, however running the Query in SQL Server Management Studio does present results. </p>
  
  <p>Here is what i have:</p>
  
  <pre><code>Public Sub Main()
      Dim connection As New SqlConnection(My.Settings.connectionString)
      connection.Open()
      Dim sqlCommand As SqlCommand
      log(" Processing - Searching SQL Database for Held ONLN Jobs ")
  
   Dim sqlQ1 As String = "Select [JobID] FROM [cemail].[dbo].[JobTb] " +
                 "WHERE ApplicationID = 7 AND Status = 10 ORDER BY [JobID]"
  
      sqlCommand1 = New SqlCommand(sqlQ1, connection)
      Dim result = sqlCommand1.ExecuteScalar()
  
     Dim sqlQ2 As String = "Select [JobID],[JobNumber],[ApplicationID],[GeneratedDate]," +
                  "[ReceivedDate],[CompletedDate],[Status],[ExpectedRecordNumber]," +
                  "[ReceivedRecordNumber],[BadRecordNumber] " +
                  "FROM [cemail].[dbo].[JobTb] " +
                  "WHERE ApplicationID = 7 AND Status = 10"
      sqlCommand2 = New SqlCommand(sqlQ2, connection)
      Dim reader As SqlDataReader = sqlCommand2.ExecuteReader()
      While reader.Read()
          Dim jobID = reader(0)
          Dim jobNumber = reader(1)
          Dim appID = reader(2)
      End While
  
      If (result &gt; 0) Then
  
   SendEmail(My.Settings.emailuser1, "Current Held Jobs", "Hello," &amp; jobID &amp; "Kind Ragards" )
      Else
  
          SendEmail(My.Settings.emailuser1, "No Jobs on Hold", "There are no Jobs Currently on Hold" )
  
  
      End If
  
  
      connection.Close()
  
      log("Finished")
  End Sub
  </code></pre>
  
  <p>Any help on this would be greatly appreciated. thanks in Advance.</p>