Using a ICollection Value in sqlite SELECT parameterized statment

Posted by case23 on Stack Overflow See other posts from Stack Overflow or by case23
Published on 2010-05-22T09:27:24Z Indexed on 2010/05/22 9:30 UTC
Read the original article Hit count: 277

Filed under:
|

Im trying to get all the entrys from a sqlite Database which have the same name as the keys in a Hashtable.

My Statement looks like this.

// the keys from the hashtable are names equivalent 
// to name entrys in the SomeTable Names Collumn
Hashtable names;

String query = "SELECT Id, Name FROM SomeTable WHERE Name LIKE (@Names)";
SQLiteCommand command = new SQLiteCommand(query, _databaseConnection);
command.Parameters.AddWithValue("@Names", names.Keys);
SQLiteDataReader reader = reader.ExecuteReader();

while(reader.Read())
{
     Console.WriteLine("Name: {0}, ID: {1}", reader[1].ToString(), reader[0].ToString());
}

Im totally sure there are similar values in the Database, but i get nothing back and the reader does not execute. Is it impossible to add a ICollection as a Parameter Value so i need to start the reader only one time?

© Stack Overflow or respective owner

Related posts about c#

Related posts about sqlite