Trying to execute the following query on northwind access database throws an exception:
No value given for one or more required parameters
My simplified query is
SELECT * FROM (SELECT [Orders].[OrderDate] FROM [Orders]) t
WHERE [Orders].[CustomerID]=?
The exception is only thrown if nested SELECT is used.
Question: is there a way to use nested SELECT and parameters?
My code is:
OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + _databasePath);
conn.Open();
OleDbCommand com = new OleDbCommand(@"SELECT *
FROM (SELECT [Orders].[OrderDate] FROM [Orders]) t
WHERE [Orders].[CustomerID]=?", conn);
com.Parameters.Add("Bla", OleDbType.WChar);
com.ExecuteReader(CommandBehavior.CloseConnection);