当前位置: 首页>>代码示例>>C#>>正文


C# ErrorLogger.ErrorLog方法代码示例

本文整理汇总了C#中ErrorLogger.ErrorLog方法的典型用法代码示例。如果您正苦于以下问题:C# ErrorLogger.ErrorLog方法的具体用法?C# ErrorLogger.ErrorLog怎么用?C# ErrorLogger.ErrorLog使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ErrorLogger的用法示例。


在下文中一共展示了ErrorLogger.ErrorLog方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: deleteItem

 public static string deleteItem(string itemId)
 {
     ErrorLogger log = new ErrorLogger();
     log.ErrorLog(HttpContext.Current.Server.MapPath("Logs/Delete"), "Item with ID " + itemId + " deleted from database.");
     bool success = CatalogAccess.DeleteItem(itemId);
     return success ? "Item deleted successfully." : "There was an error processing your request.";
 }
开发者ID:jaysan1292,项目名称:COMP2098-Website-Project,代码行数:7,代码来源:ItemManager.aspx.cs

示例2: ExecuteNonQuery

    // Execute an update, delete, or insert command
    // and return the number of affect rows
    public static int ExecuteNonQuery(DbCommand command)
    {
        // the number of affected rows
        int affectedRows = -1;

        // Execute the command making sure the connection gets closed in the end
        try {
            command.Connection.Open();
            // Execute the command and get the number of affected rows
            affectedRows = command.ExecuteNonQuery();
        } catch (Exception ex) {
            // Log eventual errors and rethrow them
            ErrorLogger error = new ErrorLogger();
            error.ErrorLog(HttpContext.Current.Server.MapPath("Logs/ExecuteNonQueryErrorLog"), ex.Message);
            throw;
        } finally {
            // Close the connection
            command.Connection.Close();
        }
        return affectedRows;
    }
开发者ID:jaysan1292,项目名称:COMP2098-Website-Project,代码行数:23,代码来源:GenericDataAccess.cs

示例3: ExecuteScalar

    // Execute a select command and return a single result as a string
    public static string ExecuteScalar(DbCommand command)
    {
        // The value to be returned
        string value = "";

        // Execute the command making sure the connection gets closed in the end
        try {
            // Open the connection of the command
            command.Connection.Open();

            // Execute the command and get the number of affected rows
            value = command.ExecuteScalar().ToString();
        } catch (Exception ex) {
            // Log eventual errors and rethrow them
            ErrorLogger error = new ErrorLogger();
            error.ErrorLog(HttpContext.Current.Server.MapPath("Logs/ExecuteScalarErrorLog.txt"), ex.Message);
            throw;
        } finally {
            // Close the connection
            command.Connection.Close();
        }
        // Return the result
        return value;
    }
开发者ID:jaysan1292,项目名称:COMP2098-Website-Project,代码行数:25,代码来源:GenericDataAccess.cs


注:本文中的ErrorLogger.ErrorLog方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。