Did you try
var squery = cx.Query<DictDatabase>("SELECT * FROM DictTable WHERE Word LIKE ?", sel[e.Position].Character + "%" ); ?
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi there. I'm have a trouble trying to find in my table elements witch starts with a specified character using this code:
using (SQLite.SQLiteConnection cx = new SQLite.SQLiteConnection(dbPath))
{
var squery = cx.Query<DictDatabase>("SELECT * FROM DictTable WHERE Word LIKE ?", sel[e.Position].Character );
dict_lst = squery.ToList();
}
I'll try using this "... LIKE ?%" in the query, but have a message error saying 'input incomplete'
I try to use linq too, but for some reason i have another message saying 'System.AggregateException'
using this code.
var _dictionario = from dct in dbconnection.Table<DictDatabase>()
where dct.Word.Contains(sel[e.Position].Character)
select dct;
dict_lst = _dictionario.ToListAsync().Result; // message error in this line
I don't know if the error message is why I'm using another linq querying another table before this code line
so I opt for use the Query statement, also to know how use it.
thanks in advance
Did you try
var squery = cx.Query<DictDatabase>("SELECT * FROM DictTable WHERE Word LIKE ?", sel[e.Position].Character + "%" ); ?
Your code should be useful, no matter I use sql or linq for testing, there is no problem.
using (SQLiteConnection m_dbConnection = new SQLiteConnection(@"Data Source=C:\...\MyDatabase1.sqlite;"))
{
m_dbConnection.Open();
string sql = "SELECT * FROM highscores WHERE name LIKE ?";
using (SQLiteCommand command = new SQLiteCommand(sql, m_dbConnection))
{
command.Parameters.AddWithValue("param1", "(%");
command.ExecuteReader();
....
}
}
So I guess sel[e.Position].Character
may be wrong, it is not the expected ‘(’.
Try to add a breakpoint and check its value.
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.