protected int getRowCount()
{
int RowCount = 0;
SqlConnection conRowCount = new SqlConnection(ConfigurationManager.ConnectionStrings["connMSJ"].ConnectionString);
SqlCommand cmdRowCount = new SqlCommand("SELECT Category FROM MonthlyBudget WHERE (Username=@username AND CurrentMonth=@current) GROUP BY Category", conRowCount);
cmdRowCount.Parameters.AddWithValue("@username", Master.getUsername);
for (int i = 0; i < intMonth.Length; i++)
{
cmdRowCount.Parameters.AddWithValue("@current", Convert.ToDateTime("1/" + intMonth[i] + "/" + ddlYear.SelectedItem.Text));
conRowCount.Open();
SqlDataReader dtrRowCount = cmdRowCount.ExecuteReader();
if (dtrRowCount.Read())
++RowCount;
cmdRowCount.Parameters.Remove("@current");
dtrRowCount.Close();
conRowCount.Close();
}
return RowCount;
}
i want to only compare the years since i am going to produce a yearly report.
this code is can't work due to some error of the parameters values passing.