4
I’m doing a vehicle registration, I need it to register put that whenever a vehicle is registered the value zero instead of putting the value null, I tried by default, but it does not record the information.
I am using SQL Server along with C# in visual studio.
Controller class:
public ActionResult Adiciona(VeiculoModel viewModel)
{
if (ModelState.IsValid)
{
Veiculo Veiculo = viewModel.CriaVeiculo();
dao.Adiciona(Veiculo);
//return View();
return RedirectToAction("Form");
}
else
{
return View("Index", viewModel);
}
}
DAO class:
public void Adiciona(Veiculo post)
{
ITransaction tx = session.BeginTransaction();
session.Save(post);
tx.Commit();
}
How is the insertion being done? Can put the command being used?
– Sorack
I haven’t put it in the middle of programming yet, but there are some inserts here that show you how it works.
– Guilherme Padovam
I don’t understand what difference it would make, since when I run select in a numeric variable, if it is null, it will come zeroed. unless you are using a numeric variable that can be null (decimal? , double? , etc...)
– Rovann Linhalis
is a numeric variable, in case it would be an integer, is that I need it to be zero, because in another class, will compare this value with a new one that will overlap
– Guilherme Padovam
exactly.... if it is an integer, it will never be null, it is always initialized with 0
– Rovann Linhalis