developer2012
asked on
How to write a function which checks for the data value and returns a boolean value
Hi Everyone,
I am trying to write a function in c# and I have a query in it and the function should return true if the data value is not null?
How can I write this function in C#?
Thanks,
D.
I am trying to write a function in c# and I have a query in it and the function should return true if the data value is not null?
How can I write this function in C#?
Thanks,
D.
so you have to query a database? please post your code so far.
ASKER
Here is my code
And the above code throws an error ' The code function path does not return any value'
public bool CheckID(string attnum)
{
string _depid = null;
if (!(attnum == null))
{
string ConString = "User Id=t;Password=t;Data Source=T";
using (OracleConnection con = new OracleConnection(ConString))
{
OracleDataAdapter adapter = new OracleDataAdapter();
con.Open();
OracleCommand command = new OracleCommand("Select ID from Employees Where ID > 0 AND ID Is not NULL AND Attr_Num = '" + attnum + "' ", con);
adapter.SelectCommand = command;
DataSet dataset = new DataSet("ATTID");
adapter.Fill(dataset);
foreach (DataRow dr in dataset.Tables[0].Rows)
{
_depid = dr["ID"].ToString();
}
con.Close();
}
if(!(_depid == null))
return true
}
}
And the above code throws an error ' The code function path does not return any value'
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.