From 475050ba4b79b72ec158cbcac88100601c491689 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Sat, 23 Dec 2017 20:47:59 +0100 Subject: [PATCH] Fixed a null DBReader situation --- Database/Database-Financials.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Database/Database-Financials.cs b/Database/Database-Financials.cs index 6803c7f8..c88e5056 100644 --- a/Database/Database-Financials.cs +++ b/Database/Database-Financials.cs @@ -234,7 +234,7 @@ namespace Swarmops.Database } } - [Obsolete ("This method uses floating point for financials. Deprecated. Do not use.")] + [Obsolete ("This method uses floating point for financials. Deprecated. Do not use.", true)] public double GetFinancialAccountBalanceTotal (int financialAccountId) { using (DbConnection connection = GetMySqlDbConnection()) @@ -273,10 +273,13 @@ namespace Swarmops.Database { if (reader.Read()) { - return reader.GetInt64 (0); + if (!reader.IsDBNull(0)) + { + return reader.GetInt64(0); + } } - throw new ArgumentException ("Unknown Account Id"); + return 0; // Balance appears to be zero } } } @@ -1211,7 +1214,10 @@ namespace Swarmops.Database { if (reader.Read()) { - return reader.GetInt64(0); + if (!reader.IsDBNull(0)) + { + return reader.GetInt64(0); + } } return 0; // zero balance, apparently.