OK I tried it like this and still no update:(
Private Sub CheckForClosedContract()
' set internal error flag to false
m_Error = False
' create SQL string to obtain active jobs
m_strSQL = "SELECT COUNT(jobid) AS TotalRecords FROM tblJobs WHERE (contractid = @contractid) AND (active = @active)"
' set properties of the oledbcommand object
m_odcJob.CommandType = CommandType.Text
m_odcJob.CommandText = m_strSQL
' set the parameter details
m_odcJob.Parameters.Add("@contractid", m_ContractID)
m_odcJob.Parameters.Add("@active", -1)
' check if the connection is set and open
If m_odcJob.Connection Is Nothing Then
m_odcJob.Connection = m_objConn
m_odcJob.Connection.Open()
End If
' try to obtain the count of active jobs, if there are any return, otherwise contract jobs are all closed
' so close contract
Try
If CType(m_odcJob.ExecuteScalar(), Integer) Then
Return
Else
' create SQL string to archive the contract with this contractid
m_strSQL = "UPDATE tblContracts SET active = 0 WHERE (contractid = @contractid)"
' set properties of the oledbcommand object
m_odcJob.CommandType = CommandType.Text
m_odcJob.CommandText = m_strSQL
' set the parameter details
m_odcJob.Parameters.Add("@contractid", m_ContractID)
' execute the delete query
m_odcJob.ExecuteNonQuery()
End If
Catch objException As Exception
ShowError("Location: Class Job" & ControlChars.CrLf & ControlChars.CrLf & _
"Procedure: CheckForClosedContract()" & ControlChars.CrLf & _
ControlChars.CrLf & "Error Text: " & objException.Message)
' set internal error flag to true
m_Error = True
Finally
' if the connection is open then close it
If m_odcJob.Connection.State = ConnectionState.Open Then
m_odcJob.Connection.Close()
End If
End Try
End Sub
Might it have something to do with the call to m_odcJob.ExecuteNonQuery()? Is there something that might need resetting??