9
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();

I am trying to add the @login parameter to the above query but it was not adding, Can anyone help me to fix this ?

2
  • First thing I saw is that the new login parameter is never assigned a ParameterDirection. Commented Jan 23, 2017 at 17:16
  • 2
    Bad habits to kick : using old-style JOINs - that old-style comma-separated list of tables style was replaced with the proper ANSI JOIN syntax in the ANSI-92 SQL Standard (25 years ago) and its use is discouraged Commented Jan 23, 2017 at 19:30

1 Answer 1

11

Use a colon instead (: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";
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.