Error saving SQLITE: table .. has in column named

Asked

Viewed 714 times

0

inserir a descrição da imagem aqui

Error when saving the image path in SQLITE. Says it does not have a column named pathImage in the products table attached to the image with the error for better understanding.

My Dao Product Class:

import android.content.ContentValues;
import android.database.Cursor;
import br.gestaoBd.Beans.Produto;
import br.gestaoBd.Login;
import java.util.ArrayList;

public class ProdutoDao {

public void inserirProduto(Produto produto) {
    System.out.println("Inserindo produto...");
    ContentValues v = new ContentValues();
    v.put("descricao", produto.getDescricao());
    v.put("precoDeCusto", produto.getPrecoDeCusto());
    v.put("percDeLucro", produto.getPercDeLucro());
    v.put("precoDeVenda", produto.getPrecoDeVenda());
    v.put("pathImagem", produto.getPathImagem());


    Login.db.insert("produtos", null, v);
    //ProjetoBd.db.close();
    System.out.println("Inseriu...");
}

public static void alterar(Produto produto) {
    ContentValues cv = new ContentValues();
    cv.put("descricao", produto.getDescricao());
    cv.put("precoDeCusto", produto.getPrecoDeCusto());
    cv.put("percDeLucro", produto.getPercDeLucro());
    cv.put("precoDeVenda", produto.getPrecoDeVenda());
    cv.put("pathImagem", produto.getPathImagem());

 .........  

Bank structure

     ........

    sb = new StringBuilder();
    sb.append(" CREATE TABLE IF NOT EXISTS [produtos] (");
    sb.append(" [id] INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,");
    sb.append(" [descricao] VARCHAR2(50) NOT NULL,");
    sb.append(" [precoDeCusto] DOUBLE NOT NULL,");
    sb.append(" [percDeLucro] DOUBLE NOT NULL,");
    sb.append(" [precoDeVenda] DOUBLE NOT NULL,");
    sb.append(" [pathImagem] VARCHAR2(125) NOT NULL)"); 

     .........
  • The image cuts out the most important part of the error. Put it as text itself. Only the header suffices. It seems to be all in order, but the INSERT is a little weird, I don’t know if it’s something from the Android ORM. Have you tried to list the bank structure to make sure the column is there?

  • @ bigown ERROR: Sqlitedatabase android.database.sqlite.SQLiteException: table produtos has no column named pathImagem (code 1): , while compiling: INSERT INTO produtos(percDeLucro,descricao,pathImagem,precoDeVenda,precoDeCusto) VALUES (?,?,?,?,?)

  • Check the creation of the database, if the columns are being created correctly.

  • I’ve already done it. As far as I can tell, they’re properly created.

1 answer

0


I reinstalled the application and it worked perfectly. Thank you all.

  • Do not use the answer area to thank or comment, use the comment area instead. The answer area should only be used to answer the question.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.