Executing a parmeterized SQL string

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
cma
Posts: 1
Joined: Thu 02 Feb 2012 17:57

Executing a parmeterized SQL string

Post by 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?

Pinturiccio
Devart Team
Posts: 2141
Joined: Wed 02 Nov 2011 09:44

Post by 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

Post Reply