伙计们,我有一个返回 3 个值的查询(-4.00、-7.53、-15.00。我在名为 ReaderResult 的列表中返回这些值,如代码所示,但是当它们被添加到列表中时,我还想保留元素的总数被添加到列表中
DataReader = DoQuery(" select oa.[OtherAmount] FROM [Biatss_PC_SRV].[Pax].[SalesDocumentOtherAmount] as oa "
+"INNER JOIN [Biatss_PC_SRV].[Pax].[SalesRelatedDocumentInformation] as rd on oa.RelatedDocumentGuid = rd.RelatedDocumentGuid "
+"INNER JOIN [Biatss_PC_SRV].[Pax].[SalesDocumentHeader] as h on rd.HdrGuid = h.HdrGuid where h.DocumentNumber = '" + txtTicketNumber.Text.ToString() + "'");
//check DataReader
if (DataReader == null)
{
DataReader.Close();
DataReader.Dispose();
}
else
{
if (DataReader.HasRows)
{
//setting variables to be used to initial values
ii = 0;
double sumOfTaxes = 0;
ReaderResult.Clear();
while (DataReader.Read())
{
//for ( ii = 0; ii < DataReader.FieldCount; ii++)
//{
if (DataReader.IsDBNull(0))
{
string CaseNull = "";
ReaderResult.Add(CaseNull);
}
else
{
//put results in LIST<>
ReaderResult.Add(Convert.ToString(DataReader.GetDecimal(0)));
//double sumLaSa =+ Convert.ToDouble(ReaderResult.Last()); VALUE HERE IS ONLY THE LAST OF THE 3 NOT THE SUM
//sumOfTaxes =+ Convert.ToDouble(DataReader.GetDecimal(0));
//double sumLaSa =+ Convert.ToDouble(ReaderResult.Last().Last()); ERROR I GET HERE says cannont convert char to double
myTextboxListForAmounts[ii].Text = Convert.ToString(DataReader.GetDecimal(0));
// }
if (ii > 6)
{
//make txtXT visible and display summed up amount in it
lblXT.Visible = true;
txtXT.Visible = true;
txtXT.Text = Convert.ToString(sumOfTaxes);
}
ii++;
}
}
}
else
{
DataReader.Close();
DataReader.Dispose();
}
DataReader.Close();
DataReader.Dispose();
}
请问如何获得返回值的总和?