Here is my code
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"
I also used cmd.Parameters.AddWithValue but not worked...
Where is the mistake?
concatenate the parameter in your string, eg
LIKE '%' || @tags_tags || '%'
you are enclosing the parameter with single quotes, thus making it a value. remove the single quotes and concatenate the percent symbol on the value of the parameter.
LIKE @tags_tags
and in your parameters,
cmd.Parameters["@tags_tags"].Value = '%' + tags + '%';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With