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?
Executing a parmeterized SQL string
-
- Devart Team
- Posts: 2420
- Joined: Wed 02 Nov 2011 09:44
dotConnect for Oracle supports parameters. The following code demonstrates how to use a parameter in your case:
For more information please refer to http://www.devart.com/dotconnect/oracle ... eters.html
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;