Hi all,
I want to create a function in c# which receives a paramater (name of a field from a table in oracle)
The function will have to return the distinct values of the specific field.I don't know how to insert the parameter into the
select distinct(parameter) from table sql statement
I hope that you understood me.
Thank you.

Recommended Answers

All 4 Replies

Are you forming the SQL statement in the code or on the database server as a stored procedure?

Yes, i form the SQL statement in the code as the CommandText of an OleDbCommand that I use with a DataReader.

Ok, in that case you can use String.Format() to build the query string.

myCommand.CommandText = String.Format("SELECT DISTINCT({0}) FROM TheTable", theFieldName);

You can use parameters, but this is by far the quickest and simplest way.

Thank you!This solved my problem.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.