这里是我的代码SQLite准备语句不工作SQLiteDateReader?
SQLiteConnection connection = new SQLiteConnection("Data Source=userData.dat;version=3;");
connection.Open();
SQLiteCommand cmd = connection.CreateCommand();
cmd.CommandText = "SELECT * FROM tags WHERE tags_tags LIKE '%@tags_tags%' ORDER by tags_id DESC LIMIT 0, 100";
cmd.Parameters.Add("@tags_tags", DbType.String);
cmd.Parameters["@tags_tags"].Value = tags;
SQLiteDataReader reader = cmd.ExecuteReader();
var _sql = cmd.CommandText;
MessageBox.Show(_sql);//still shows "SELECT * FROM tags WHERE tags_tags LIKE '%@tags_tags%' ORDER by tags_id DESC LIMIT 0, 100"
我也用cmd.Parameters.AddWithValue
但不工作的...
哪里错了吗?
你尝试捕获所有异常? – KMC
没有任何错误。唯一的问题是我的查询仍然没有准备好 –
在命令文本中看不到具有替换变量的完整查询。您必须启动SQL Profiler并记录发送到服务器的查询。在那里你会有完全相同的查询,但也有定义的变量。 – KeepAlive