-1
I’m learning to use sqlite.net
in the Xamarin
, but when editing an item is not working, I debug the code and gave a breakpoint
in the EditItens()
and saw that the values passed to conexao.Query<Itens>
are correct, but received in the variable Teste
below continue the same as before, I’m missing something at the time of editing the values in sqlite? Also there may be something wrong in GetItens()
, but I find it kind of hard because it works normally when used to take the values and show in the ListView
of MainActivity
. Below the methods cited
string pasta = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
public List<Itens> GetItens()
{
try
{
var conexao = new SQLiteConnection(System.IO.Path.Combine(pasta, "Itens.db3"));
return conexao.Table<Itens>().ToList();
}
catch (Exception)
{
return null;
}
}
public bool EditItens(Itens itens)
{
try
{
var conexao = new SQLiteConnection(System.IO.Path.Combine(pasta, "Itens.db3"));
conexao.Query<Itens>("UPDATE Itens set Nome=?,Preco=? Where Id=?", itens.Nome, itens.Preco, itens.Id);
Teste = GetItens();
return true;
}
catch (Exception)
{
return false;
}
}
If you could tell me where I can find the pasta, "Itens.db3"
by Windows File Explorer, it will also help because I can check if the item really isn’t being edited.
I could not solve, but I rewrote another project from scratch and the error did not happen, I will leave the project here to analyze in the future pq still n understood pq was not going, but at least I know that "understood" sqlite
– underfilho
I was able to solve it, the error was in the past id, I already caught the id when doing Getitens() (in another part of the code), but even so I equalized again, I think somehow it caused the error, I realized that when I started the other project, agr I have two very similar projects and both working. The good is I fixed the content really
– underfilho