Page 1 of 1

Executing a parmeterized SQL string

Posted: Thu 02 Feb 2012 19:53
by cma
I want to create a SQL string with some parameters in it like this:

string sql = "select field1 From mytable where field2 = @param"

then I want to add a parameter to my command object and execute it. How do I get the command object to recognize that there is a parameter is the string that need to be replaced?

Posted: Fri 03 Feb 2012 17:01
by Pinturiccio
dotConnect for Oracle supports parameters. The following code demonstrates how to use a parameter in your case:

Code: Select all

OracleCommand comm = new OracleCommand("select field1 From mytable where field2 = :param", conn);
comm.Parameters.Add("param", OracleDbType.Number, 38, "deptno");
comm.Parameters["param"].Value = 132;
For more information please refer to http://www.devart.com/dotconnect/oracle ... eters.html