0

I have a SQLite database with a parameters table in the form:

'paramIdNum' INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE
'paramTypeNum' INTEGER
'name' CHAR
'value' CHAR

along with more columns that I'm not currently interested in.

I want to select 35 of the almost 300 rows for further processing, and the current way I'm doing this is to simply select each one I want, one by one, and store it in a variable:

sqliteCommand.CommandText = "SELECT value FROM parameters WHERE paramIdNum='52'"
reader = sqliteCommand.ExecuteReader();
reader.Read();
param52 = reader["value"].ToString();
reader.Close();

Is there a better way to do this?

Syzo
  • 21
  • 2
  • Why don't you write a helper function that reads a parameter? – CL. Oct 24 '13 at 14:58
  • This actually was in a function, I was just wondering if there was a different way to get all the values at once instead of doing 35 different queries, or doing a "IN (26, 35, 75, ...)" and looping through the result list with a switch-case. – Syzo Oct 24 '13 at 15:11
  • I wonder what's wrong with `IN (26, 35, 75, ...)`? Probably I would do it this way. – Michał Powaga Oct 24 '13 at 15:20
  • Is there at least a way of binding a list of ints to do this? The Mono.Data.Sqlite documentation is seemingly nonexistent. – Syzo Oct 24 '13 at 15:27
  • I think that you'll will have to do it this way http://stackoverflow.com/a/2377651/1027198 or if you are 100% sure that those parameters are only safe integers you can just concat them. If this a input from user do it described in attached answer way. – Michał Powaga Oct 24 '13 at 16:49

0 Answers0