I'm trying to query the Microsoft Indexing Service catalog, and I've found a bunch of really helpful articles about it (like this one), but every example I find they just use string concatenation to build queries, and it feels so wrong on so many different levels.
I clearly want to use parameterized queries, but it looks like the MS Indexing provider doesn't support them, as described by the following exception:
The ICommandWithParameters interface is not supported by the 'MSIDXS' provider. Command parameters are unsupported with the current provider.
Here's a simplified example of my code. All I want to do is run a really simple query, and protect against bad input.
OleDbCommand cmd = new OleDbCommand("select DocTitle, Path from scope() where @friendlyName = '@value'", ActiveConnection());
cmd.Parameters.Add(new OleDbParameter("@friendlyName", friendlyName));
cmd.Parameters.Add(new OleDbParameter("@value", value));
OleDbDataAdapter da = new OleDbDataAdapter(cmd);
DataSet results = new DataSet();
da.Fill(results);
If I'm really forced to use string concatenation, what's the best way to sanitize the inputs? How will I know I covered all the cases?