문제

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"

도움이 되었습니까?

해결책

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
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top