Can anyone see why this would not work?
When I step through the code it does not error and runs the code m_odcJob.ExecuteNonQuery() but when I check the contracts table its active field remains unchanged?
Code:
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 = ?) AND (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", True)
check if the connection is set and open it if not
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 = ?)"
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
When I step through the code it does not error and runs the code m_odcJob.ExecuteNonQuery() but when I check the contracts table its active field remains unchanged?