Executing a parmeterized SQL string

Executing a parmeterized SQL string

Postby cma » Thu 02 Feb 2012 19:53

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?
cma
 
Posts: 1
Joined: Thu 02 Feb 2012 17:57

Postby Pinturiccio » Fri 03 Feb 2012 17:01

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
Pinturiccio
Devart Team
 
Posts: 1954
Joined: Wed 02 Nov 2011 09:44


Return to dotConnect for Oracle