2017-01-23 3 views
0
string sqlCmd = @"SELECT r.row_id AS resp_id, 
         r.name AS resp_name 
        FROM srb.s_resp r, 
         srb.s_per_resp pr, 
         srb.s_contact c, 
         srb.s_user u 
        WHERE r.row_id = pr.resp_id 
        AND u.row_id = c.row_id 
        AND c.person_uid = pr.per_id 
        AND UPPER(u.login) = @login 
       ORDER BY r.name"; 

OracleConnection con = new OracleConnection(getConnectionString(username, password)); 
OracleCommand command = con.CreateCommand(); 

conSiebel.Open(); 
command.CommandType = CommandType.Text; 
command.Connection = con; 
command.CommandText = sqlCmd; 

command.Parameters.Add(new OracleParameter("login", username)); 

IDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection); 
reader.Close(); 

위의 쿼리에 @login 매개 변수를 추가하려고하지만 추가하지 않았습니다. 누구든지 해결하도록 도와 줄 수 있습니까?오라클 C에서 매개 변수화 된 쿼리

+0

내가 처음 보았던 것은 새로운 로그인 매개 변수에는 결코 'ParameterDirection'이 지정되지 않는다는 것입니다. – CDove

+0

[나쁜 습관 : 오래된 스타일의 조인 사용] (http://sqlblog.com/blogs/aaron_bertrand/archive/2009/10/08/bad-habits-to-kick-using-old-style-joins. aspx) - ANSI - ** 92 ** SQL 표준 (** 25 년 ** 전)에서 구식 * 쉼표로 구분 된 테이블 * 스타일 목록이 * 적절한 * ANSI'JOIN' 구문으로 대체되었으며 사용은 권장하지 않습니다. –

답변

2

대신 콜론 (:login)을 사용하십시오.

string sqlCmd = @"SELECT r.row_id AS resp_id, 
            r.name AS resp_name 
          FROM srb.s_resp r, 
            srb.s_per_resp pr, 
            srb.s_contact c, 
            srb.s_user u 
          WHERE r.row_id = pr.resp_id 
            AND u.row_id = c.row_id 
            AND c.person_uid = pr.per_id 
            AND UPPER(u.login) = :login 
            ORDER BY r.name"; 
+0

저에게 잘 부탁드립니다. –

+0

듣기 좋습니다. 이 문제가 해결 되었다면 대답을 수락하는 것을 잊지 마십시오. – chadnt