Da cosa può dipendere questo errore:
Column 'nome' cannot be null
Nel debug sembrano esserci i parametri corretti, in quanto
return new MySqlParameter[]{
utenteNomeParameter,
utenteCognomeParameter,
utenteEmailParameter,
utentePasswordParameter
};
contengono i valori passati dal textbox
cosa sbaglio??
public virtual void Insert(WebUtente item)
{
if (item == null)
{
throw new ArgumentNullException("item", "Errore -> Elemento nullo");
}
try
{
SqlHelper.ExecuteNonQueryTxt(CommandType.Text,
insertCommandText,
GetParametersByEntity(item));
}
catch(Exception ex)
{
//Scrive l'errore nel LOG
throw;
}
}
protected virtual MySqlParameter[] GetParametersByEntity(WebUtente item)
{
MySqlParameter utenteNomeParameter = new MySqlParameter("@nome", MySqlDbType.VarChar, 150);
utenteNomeParameter.Value = item.nome;
MySqlParameter utenteCognomeParameter = new MySqlParameter("@cognome", MySqlDbType.VarChar, 150);
utenteCognomeParameter.Value = item.cognome;
MySqlParameter utenteEmailParameter = new MySqlParameter("@email", MySqlDbType.VarChar, 100);
utenteEmailParameter.Value = item.mail;
MySqlParameter utentePasswordParameter = new MySqlParameter("@password", MySqlDbType.VarChar, 60);
utentePasswordParameter.Value = item.password;
return new MySqlParameter[]{
utenteNomeParameter,
utenteCognomeParameter,
utenteEmailParameter,
utentePasswordParameter
};
}
public static int ExecuteNonQueryTxt(CommandType commandType, string commandText, params MySqlParameter[] commandParameters)
{
if( connection == null ) throw new ArgumentNullException( "connection" );
// Create a command and prepare it for execution
MySqlCommand cmd = new MySqlCommand();
MySqlConnection myconnection = new MySqlConnection(connection);
bool mustCloseConnection = false;
PrepareCommand(cmd, myconnection, (MySqlTransaction)null, commandType, commandText, commandParameters, out mustCloseConnection);
// Finally, execute the command
int retval = cmd.ExecuteNonQuery();
// Detach the MySqlParameters from the command object, so they can be used again
cmd.Parameters.Clear();
if( mustCloseConnection )
myconnection.Close();
return retval;
}