本文整理汇总了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.";
}
示例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;
}
示例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;
}