로 SQL 조건을 전달합니다내가 다음 코드를 가지고은 OleDb 매개 변수
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
모두 같은 길이 ArrayList
하지만 코드가 제대로 작동하지 않습니다. 모든 변수에 값이 있는지 확인했습니다.
나는 그것이 구문 오류를보고 코드를 실행하면 "쿼리 식에없는 작업"
문제는 ParameterCondition
같은 값을 가지고 있다는 것입니다을 ('>'
, '<'
, '='
, .... 어떤 논리적 SQL 사업자) .
편집 : 매개 변수에 조건을 포함하려면 어떻게해야합니까?
해당 조건을 매개 변수화하는 방법은 무엇입니까? 방법이 있니? – Nest
코드가 업데이트되었습니다. 이제는 더 명확 해지기를 바랍니다. –