Passing SQL Query Result into a String

Apr 28 2011 5:01 PM
Hi guys,
Can you please let me know how I can assign the result of a simple SQL query into a string?
Let's say I have a query like:
string cmd = "Select FName From Emp Where EmpID = 20");
OracleCommand oc = new OracleCommand(cmd, oraConnection);

As you can see the above query will return a single cell value as has been restricted by where clause.Now my question is how I can assign the cell value into a string in order to create a condition statement like
string res = result of query
if(res.StartsWith(s)
{ //do something};
else
{ //do something else};



Thanks in advance for you time


Answers (4)