Click here to Skip to main content
15,890,825 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi All!
I know Builder C++ and Delphi have Oracle components(TOracleDataSet for example) which have Substitution type. How can I get it in C#?
I tried to do this:

C#
private string query = "select * from tb_zone t where t.employee=:p1 :p2 ";
       public void test()
       {
           using (OracleConnection connection = new OracleConnection(connectionString))
           {
               connection.Open();
               OracleCommand cmd = new OracleCommand(query, connection);
               cmd.Parameters.AddWithValue("p1", 8434);
               //Substitution               
               cmd.Parameters.AddWithValue("p2", " and t.rkc is not null "); 
               MessageBox.Show( cmd.ExecuteOracleScalar().ToString());
           }
       }


But it doesn't work!
I think the query becomes like below :
select * from tb_zone t where t.employee=8434 " and t.rkc is not null "
The second parameter wrapped by quotes.
Sorry for my English :)
Posted
Updated 7-Jun-11 13:04pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900