Question

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"

Was it helpful?

Solution

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top