/// This function is used to retrive the value of a given field form the given table depending on specified criteria
///
/// Value to retied
/// Table from which values is to retived
/// filter criteria
///
public string getValue(String FieldName, String TableName, String WhereClause)
{
String SQL;
if (FieldName != string.Empty && FieldName != null && FieldName != "")
{
if (TableName != string.Empty && TableName != null && TableName != "")
{
if (WhereClause != string.Empty && WhereClause != null && WhereClause != "")
{
try
{
SQL = "Select " + FieldName + " From " + TableName + " Where " + WhereClause;
Con = Myconn.CreateConn();
Da = new MySqlDataAdapter(SQL, Con);
DS = new DataSet();
Da.Fill(DS);
return DS.Tables[0].Rows[0][0].ToString();
}
catch (Exception)
{
return "";
}
}
else
{
return "";
}
}
else
{
return "";
}
}
else
{
return "";
}
}
No comments:
Post a Comment