이미 문제가없는 매개 변수화 된 쿼리를 사용했지만 현재는 디버깅 할 수없는 오류가 있습니다. 이 내 작업 쿼리매개 변수가 작동하지 않는 Vb 2015 쿼리
cmd.CommandText = "select idcliente, ragsociale from Clienti where idcliente =" & strName & " or codiceamministrazione='" & strName & "' or piva='" & strName & "' or codfisc='" & strName & "'"
동일하지만, 매개 변수, 내부 ID 또는 상업적 기반으로 클라이언트의 이름을 표시 나는 자동 완성 과정에서 이것을 사용
cmd.CommandText = "select idcliente, ragsociale from Clienti where idcliente = @Cliente or [email protected] or [email protected] or [email protected]"
cmd.Parameters.AddWithValue("@Cliente", strName)
작동하지 않음 라이센스 번호 (및 기타 유사한 코드). db에서 클라이언트 레코드는 컴파일 된 모든 코드 필드를 가질 수 있습니다.
매개 변수가없는 쿼리에서는 매개 변수가없는 제안 팝업이 표시되고 아무 것도 표시되지 않습니다. 오류도 없습니다.
편집 : 같은 기능에서 (semplicity에 대한 이전 생략)이
cmd.Parameters.Add("@Cliente", SqlDbType.VarChar)
cmd.Parameters("@Cliente").Value = strName
지금 다른 쿼리를 사용하여이 충분히 이상한 작동하지만, 나는이 질문을 한 일의 하나는하지 않습니다.
작업 :
cmd.CommandText = "select idcliente, ragsociale from Clienti where ragsociale like '%'[email protected]+'%' or [email protected]"
여전히 작동하지 : idcliente
에 대해 테스트 할 때 원래의 쿼리에서
cmd.CommandText = "select idcliente, ragsociale from Clienti where idcliente = @Cliente or [email protected] or [email protected]"
아시다시피 '@Cliente in (idcliente, codiceamministrazione, piva, codfisc)'에 다시 쓸 수 있습니다. –
.AddWithValue!를 사용하지 마십시오! 나는 이것이 문제라고 생각한다. – muffi
[Joel Coehoorn의 블로그 글] (https://blogs.msmvps.com/jcoehoorn/blog/2014/05/12/can-we-stop-using-addwithvalue-already/)에서 muffi의 말을 되풀이합니다. –