This is the method i was using to check if there is a match of title in the data table:
public static bool checkBook(DataTable dt, String title)
{
try
{
foreach (DataRow dr in dt.Rows)
{
String checktitle = dr["Title"].ToString();
if (title == checktitle)
return true;
else
return false;
}
catch (Exception ex)
{
//do something
return false;
}
}
but there is a problem, i try to use try and catch but why there is no value return?
there is error because if there is no row in datatable nothing get returned form code so that you need to
return falselike as below in code ,Refine code for you :