1

I am using OracleCommand.Parameters in a select query for on an Oracle 11g database. The following statement works great on columns that are of type number or varchar.

string theQuery = "select * from TABLE where COLUMN = :p1";
OracleCommand Cmd = new OracleCommand(theQuery);
Cmd.Parameters.Add(new OracleParameter("p1", "2183989118"));
Cmd.Connection = Conn;
Cmd.CommandType = CommandType.Text;

The problem is that I really want to run the statement against a column of type CHAR(20 BYTE), and when I do this i never get a result. The query works if I am not using parameters and just adding '2183989118' in theQuery directly.

Am i missing something in my Parameters.Add statement?

1
  • Are you sure there is no " 2183989118" value in COLUMN. new OracleParameter("p1",OracleDbType.Char); Commented Aug 24, 2012 at 7:42

1 Answer 1

1

Try this

  Cmd.Parameters.Add("p1", OracleDbType.Char);
Sign up to request clarification or add additional context in comments.

1 Comment

I ended up editing the Parameter like this: Cmd.Parameters.Add("p1", OracleDbType.Char).Value = "2183989118"; Working great, thanks!

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.