This actually is a working application. Albeit without much in the way of error trapping.
I am just trying to log the flow and am not reaching either the If branch or the else branch. What can I do to make that happen? Neither side of the branch is logging into my txt file.
while (reader.Read())
{
if (reader.HasRows)
{
LogMessage("Further Inside Try2 ");
byte[] paymentData = (byte[])reader["payment"];
strPaymentData = ASCIIEncoding.Unicode.GetString(paymentData);
LogMessage(strPaymentData + " strPaymentData");
}
else
{
LogMessage("Payment Retrievlal Failed ");
}
}
You don't need to check if reader has rows if you're using while reader.read(). If reader returns no rows, While loop will not execute. Hence the else will never be reached if reader has no rows.
You could rewrite your code as follows:
if (reader.HasRows)
{
while (reader.Read())
{
LogMessage("Further Inside Try2 ");
byte[] paymentData = (byte[])reader["payment"];
strPaymentData = ASCIIEncoding.Unicode.GetString(paymentData);
LogMessage(strPaymentData + " strPaymentData");
}
}
else
{
LogMessage("Payment Retrievlal Failed ");
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With