Invalid operation - delete not allowedInvalid operation - delete not allowed
Old forum URL: forums.lhotka.net/forums/t/6022.aspx
ssanchez076 posted on Thursday, December 18, 2008
Hi, I've been searching for this problem during the last 4 hours with no successful answer on Google.
It's something really weird.
I'm a newbie on CSLA, and in my work they use it, right now I'm on training (based on creating an application on CSLA)
I have my page named MantenimientoPaises.aspx (I speak spanish and i hate to code in spanish, but i'ts just an standard here). It's basically to manage countries. I need to do insert, updates and deletion. Insert and updates are fine, just the update don't work. The exception is Invalid operation - delete not allowed.
[Code in MantenimientoPaises.aspx]
protected void ListaPaisDataSource_DeleteObject(object sender, Csla.Web.DeleteObjectArgs e)
{
try
{
//PAIS_ID = "IdPais"
Pais.EliminarPais(int.Parse(e.Keys[PAIS_ID].ToString()));
Session[CURRENT_OBJECT] = null;
e.RowsAffected = 1;
}
catch (Csla.DataPortalException ex)
{
this.ErrorLabel.Text = ex.BusinessException.Message;
e.RowsAffected = 0;
}
catch (Csla.Validation.ValidationException ex)
{
this.ErrorLabel.Text = ex.Message;
e.RowsAffected = 0;
}
catch (Exception ex)
{
this.ErrorLabel.Text = ex.Message;
e.RowsAffected = 0;
}
}
[Code in Pais.cs]
//Constructor
private Pais()
{
}
//Factory Method
/// <summary>
/// Deletes a country
/// </summary>
/// <param name="ai_IdPais">Id del pais a eliminar</param>
public static void EliminarPais(int ai_IdPais)
{
DataPortal.Delete(new SingleCriteria<Pais, int>(ai_IdPais));
}
//Data Access
//[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_DeleteSelf()
{
DataPortal_Delete(new SingleCriteria<Pais, int>(ii_IdPais));
}
//[Transactional(TransactionalTypes.TransactionScope)]
private void DataPortal_Delete(SingleCriteria<Jornada, int> criteria)
{
using (SqlConnection lcon_Conexion = new SqlConnection(Test.Library.Admin.Database.ConnectionString))
{
lcon_Conexion.Open();
using (SqlCommand lcmd_Sentencia = new SqlCommand(STORED_PROCEDURE_PAIS_DELETE, lcon_Conexion))
{
lcmd_Sentencia.CommandType = CommandType.StoredProcedure;
lcmd_Sentencia.Parameters.AddWithValue(PAIS_PARAMETRO_ID, criteria.Value);
lcmd_Sentencia.ExecuteNonQuery();
}
} // using cn
}
I put down a breakpoint in EliminarPais and it gets there. After it calls DataPortal.Delete the program gets an exception. I don't know why it gets an exception and don't enter to DataPortal_DeleteSelf or DataPortal_Delete.
Any help?
Thank you
ssanchez076 replied on Thursday, December 18, 2008
A copy paste mistake... I'm very sorry. Please delete this
Thank you
elwindows replied on Tuesday, September 29, 2009
ssanchez076: A copy paste mistake... I'm very sorry. Please delete this
Thank you
I got the same error. Seeing your post I realized it was copy/paste too.
Thank you! ;)
Copyright (c) Marimer LLC