Skip to content
Advertisement

How to add parameters in a SQL select query?

How to add parameters in a SQL select query?

string time = 2013-09-25 00:00:00;

I wish to use the time variable in the below mentioned SQL query

Select LastUpdated from Employee where LastUpdated > time;

Advertisement

Answer

I just framed my question in a wrong, the query remains the same though. I just wanted time to be added as a paramter in my SQL-query. The code for the same looks like

String commandText = "Select LastUpdated from Employee where LastUpdated > :time;";
OracleConnection connection = new OracleConnection(connectionString);
OracleCommand command = new OracleCommand(commandText, connection);
command.Parameters.Add("time", time);

Thanks a lot for your help! My bad that I couldn’t frame the question properly.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement