private void getCount()
{
SqlCommand cmdCountPenalty = new SqlCommand("SELECT PenaltyID FROM Penalty", conOOC);
SqlCommand cmdCountBill = new SqlCommand("SELECT BillID FROM Bill", conOOC);
SqlCommand cmdCountPayment = new SqlCommand("SELECT PaymentID FROM Payment", conOOC);
conOOC.Open();
SqlDataReader dtrCountPenalty = cmdCountPenalty.ExecuteReader();
while (dtrCountPenalty.Read())
{
++countPenalty;
}
dtrCountPenalty.Close();
SqlDataReader dtrCountBill = cmdCountBill.ExecuteReader();
while (dtrCountBill.Read())
{
++countBill;
}
dtrCountBill.Close();
SqlDataReader dtrCountPayment = cmdCountPayment.ExecuteReader();
while (dtrCountPayment.Read())
{
++countPayment;
}
dtrCountPayment.Close();
conOOC.Close();
i'd declared countPenalty, countBill, countPayment as global variables and assgined = 1
(public static int countPenalty = 1, countBill = 1, countPayment = 1;)
every one counting were correct except countBill. The Result i get from countBill
(1st time = 1, 2nd time = 3). by right the 2nd time should be = 2. any idea what i am did wrong? @@