This method takes an input parameter (email address). If it exists in the table then it returns the value (email), if it doesn’t then it shouldn’t be returning any value but this method keeps on returning the same value (parameter) all the time.
Am I missing something?
private static string findEmailSubscription(string emailAddress)
{
try
{
//Fetch email Address
using (DataAccess data = new DataAccess("Email"))
{
DynamicEntity[] emails = data.Adapter.Execute(
"SELECT EmailAddress FROM table " +
"WHERE EmailAddress=@EmailAddress; ",
ExecuteCommandType.Text,
new Object[,] {
{"EmailAddress", emailAddress ?? (object)DBNull.Value}
});
}
return emailAddress;
}
Look at your code:
That’s unconditional. You’re not using your
emailsvariable at all. How did you expect this to work? (Not that this can be your complete code anyway, given that you have atryblock with nocatchorfinally…)Note that a method with a return type can’t “return no value”. It could never return (not good), throw an exception, or return a value. That’s all it can do. It could return a null reference… is that what you want it to do?