Pergunta

I`m using this code to search for a number in a sqlite Table

String insSQL2 = "select * from Produtos where nome =" + txtBuscaNome.Text;

but when I try to use it to search for a name I get an error. Why?

The error I get is

System.Data.SQLite.SQLiteException was unhandled

SQL logic error or missing database

no such column: "the text I typed"

Foi útil?

Solução

Ignoring the fact that your code is completely open to SQL Injection, you need to enclose strings in single quotes in SQL.

So your code should be this:

String insSQL2 = 
    "select * from Produtos where nome = '" + txtBuscaNome.Text + "'";
//                                       ^^ here                   ^^ here
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top