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"

Était-ce utile?

La 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
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top