I have following code:
Dim executedCmd As OleDb.OleDbCommand = m_dbMgr.GetCommand()
executedCmd.CommandText = "select * from [Parameters] where "
Dim SQLcondition As String = String.Empty
For i As Integer = 0 To ParameterName.Count - 1
executedCmd.CommandText += "ParameterName = @parametername" + i.ToString() + " and ParameterValue @ParamaterCondition" + i.ToString() + " @ParameterValue" + i.ToString()
executedCmd.Parameters.AddWithValue("@parametername" + i.ToString(), ParameterName(i))
executedCmd.Parameters.AddWithValue("@ParameterValue" + i.ToString(), ParameterValue(i))
executedCmd.Parameters.AddWithValue("@ParamaterCondition" + i.ToString(), Condition(i))
Next
ParameterName
, ParameterValue
, ParameterCondition
all are same length ArrayList
, but the code does not work properly. I have verified all the variables have values.
When I run the code it reports a syntax error: "missing operations in query expression"
The problem is that ParameterCondition
has values like ('>'
, '<'
, '='
,.... some logical SQL operators).
Edit: How can I include conditions in parameters?