Ama*_*man -1 c# sqlite system.data.sqlite
我正在使用此代码在sqlite表中搜索数字
String insSQL2 = "select * from Produtos where nome =" + txtBuscaNome.Text;
Run Code Online (Sandbox Code Playgroud)
但当我尝试使用它来搜索名称时,我收到一个错误.为什么?
我得到的错误是
System.Data.SQLite.SQLiteException未处理
SQL逻辑错误或缺少数据库
没有这样的专栏:"我输入的文字"
忽略代码完全对SQL注释开放的事实,您需要在SQL中用单引号括起字符串.
所以你的代码应该是这样的:
String insSQL2 =
"select * from Produtos where nome = '" + txtBuscaNome.Text + "'";
// ^^ here ^^ here
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1591 次 |
| 最近记录: |