I'm using SQLite provider on c#.
I'm trying to use SQL select * from table where name like 'part_of_name%'. But this query don't work correctly. Debug write System.InvalidOperationException in application System.Data.SQLite.dll.
Example:
I have table Books(id, name) with 3 items:
- Harry Potter and the Sorcerer's Stone
- Harry Potter and the Chamber of Secrets
- Godfather
In SQLite Manager query select * from Books where name like 'Harry%' shows me 1-st and 2-nd items, but in my c# application only 1-st and debug exception. When I try ... like '%' my application shows me only 1-st item, but when I try ... like 'God%' it shows me 3-rd item.
Help me please. Thanks!
This is the code:
sqliteConn.Open(); //open connection
sqliteDA.SelectCommand = new SQLiteCommand("select * from Books where name like '" + text + "%'", sqliteConn); //create SQL-query in sqlite data adapter
dataSet.Tables["Books"].Clear(); //clear our dataset.table with old info
sqliteDA.Fill(dataSet, "Books"); //fill our dataset.table with info from sqlite data adapter
sqliteConn.Close(); //close connection
select * from Books where name='Harry Potter an the Chamber of Secrets'works correct. Exception was generated in linesqliteDA.Fill(dataset, "Books");