/// <summary> /// Receives a ReturnField, SearchExpression and field to be searched a as parameters. The function /// looks up a value and returns the value of the ReturnField on a successful /// search. The function maintains the last Order() of the view. /// Please note that unlike the VFP Lookup() command this one receives the ReturnField and SearchField as strings. /// </summary> /// <example> /// string cCustomer = vfpData.Lookup("cname", "60", "iid", oView) /// </example> /// <param name="tcReturnField"></param> /// <param name="tcSearchExpression"></param> /// <param name="tcSearchedField"></param> /// <returns></returns> public static string Lookup(string tcReturnField, string tcSearchExpression, string tcSearchedField, DataView toView) { string cRetVal = ""; //Capture the current order string cOrder = VfpData.Order(toView); try { //Set the order to the search order VfpData.SetOrderTo(tcSearchedField, toView); int nFoundRec = VfpData.Seek(tcSearchExpression, toView); //If we find a record then get the return value if (nFoundRec != -1) { cRetVal = toView.Table.Rows[nFoundRec][tcReturnField].ToString(); VfpData._Found = true; } } finally { //Cleanup to reset the old order toView.Sort = cOrder; } return(cRetVal); }
/// <summary> /// As ADO.NET does not support current position of cursors. /// This functions performs the same action as that of a seek /// </summary> /// <param name="tcExpression"></param> /// <param name="toView"></param> /// <returns></returns> public static int IndexSeek(string tcExpression, DataView toView) { return(VfpData.Seek(tcExpression, toView)); }