public static List <Error_Type> ReturnErrors(bool corrected, int UserID) { List <Error_Type> errors = new List <Error_Type>(); //our first instinct is to record an error to the database string sSQL = "SELECT * FROM dbo.ErrorTable ORDER BY ErrorID DESC"; using (Data DC = new Data("conn", "Errors", "ReturnErrors")) { try { //make an independent connection to the error database DC.AddCommand(CommandType.Text, sSQL); DataTable dt = DC.ExecuteCommandForDT(); if (dt != null) { foreach (DataRow dr in dt.Rows) { errors.Add(new Error_Type { UserID = UserID, Err_Message = dr["Err_Message"].StringSafe(), Err_Subject = dr["Err_Subject"].StringSafe(), ErrorID = (int)Utils.ParseNumControlledReturn(dr["ErrorID"]), LiteralDesc = dr["LiteralDesc"].StringSafe(), Page = dr["Page"].StringSafe(), Process = dr["Process"].StringSafe(), SQL = dr["SQL"].StringSafe(), Time_Of_Error = Utils.ParseDateControlledReturn(dr["Time_Of_Error"]) }); } } } catch (Exception ex) { DC.MakeError(ex, "ReturnErrors", sSQL); } finally { if (DC != null) { DC.Dispose(); } } } return(errors); }
public static bool UpdateError(int id, int UserID, string Desc) { bool bRet = false; string sSQL = ""; sSQL = "UPDATE dbo.ErrorTable SET Corrected = 1 WHERE ErrorID=@ID;"; using (Data DC = new Data("conn", "Errors", "UpdateError")) { try { //make an independent connection to the error database DC.AddCommand(CommandType.Text, sSQL); DC.AttachParameterByValue("@UserID", UserID); DC.AttachParameterByValue("Desc", Desc); DC.AttachParameterByValue("ID", id); int iRet = DC.ExecuteCommand(); if (iRet > 0) { bRet = true; } } catch { bRet = false; } finally { if (DC != null) { DC.Dispose(); } } } return(bRet); }