Note that there are some explanatory texts on larger screens.

plurals
  1. POUpdate SQL command doesn't affect any rows
    primarykey
    data
    text
    <p>As general question I'd like to ask what can result in an update sql command making no changes in the table without giving any error?</p> <p>Now more specifically, I have an update with no errors, all variables containing correct values, there is at least one value that's different from the one in the table, the value in the WHERE clause existing in the table and no errors given. So what is possibly going wrong?</p> <p>I'm working on Microsoft Visual Studio 2012 with an OleDB connection to MS Access 2010 (more precisly .accdb file) Here is the code:</p> <pre><code>public int updateCert(Calibracao cal, string certificadoAnterior) { OleDbConnection l = OleDbConnectionDAO.createConnection(); int result = 0; try { l.Open(); OleDbCommand cmd = l.CreateCommand(); cmd.Parameters.Add(new OleDbParameter("@data", cal.Data)); cmd.Parameters.Add(new OleDbParameter("@entidade", cal.EntidadeCal)); cmd.Parameters.Add(new OleDbParameter("@observacao", cal.Observacao)); cmd.Parameters.Add(new OleDbParameter("@certificado", cal.Certificado)); cmd.Parameters.Add(new OleDbParameter("@resultado", cal.Resultado)); cmd.Parameters.Add(new OleDbParameter("@selecionar", cal.Selecionar)); cmd.Parameters.Add(new OleDbParameter("@certificadoAnterior", certificadoAnterior)); cmd.CommandText = "UPDATE [Movimento Ferramentas] SET " + "[Data saida] = @data, " + "[Entidade] = @entidade, " + "Estado = 'Calibração', " + "[Observações1] = @observacao," + "Certificado = @certificado, " + "Resultado = @resultado " + "WHERE Certificado = @certificadoAnterior"; result = cmd.ExecuteNonQuery(); l.Close(); } catch (Exception ex) { l.Close(); System.Diagnostics.Debug.WriteLine("DAO Exception: " + ex.Message); return result; } return result; </code></pre> <p>}</p> <p>EDIT: Corrected the SET, the issue remains</p> <p>UPDATE: Problem solved with old school debugging removing everything then adding a field at the time. I don't what exactly was wrong but it ended up working. In case it helps someone else, this is how the code ended up:</p> <pre><code>cmd.Parameters.Add(new OleDbParameter("@entidade", cal.EntidadeCal)); cmd.Parameters.Add(new OleDbParameter("@data", cal.Data)); cmd.Parameters.Add(new OleDbParameter("@certificado", cal.Certificado)); cmd.Parameters.Add(new OleDbParameter("@resultado", cal.Resultado)); cmd.Parameters.Add(new OleDbParameter("@observacao", cal.Observacao)); cmd.Parameters.Add(new OleDbParameter("@certificadoAnterior", certificadoAnterior)); cmd.CommandText = "UPDATE [Movimento Ferramentas] SET " + "[Entidade] = @entidade, " + "[Data saida] = @data, " + "Certificado = @certificado, " + "Resultado = @resultado, " + "[Observações1] = @observacao " + "WHERE Certificado = @certificadoAnterior"; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload