Ok this makes no sense. Solved Somewhat
I posted all the code for the database transaction, maybe I have just been looking at it way too long but what the heck is going on. look at that page count variable especially. Simply add 1 to it. or so I think, for some reason no matter what I do it adds 2. I can;t figure this out, This is in a constructor for a class. that is just supposed to be indexing a counter and getting some data. I have tried everything I can think of but it keeps advancing 2. Anyone have any idea why. even if imediately right after that line I write out the result it is 2 more than what it was before, it is like the code is running twice but why? No I am not newing it up 2 times or anything in fact it is the only line of code on the web page, this is behind the scenes in an assembly
Code:
string SQLSelect = "Select PagePath,PageTitle,PageClass,HitCount,SecurePage,Maintenance From PageData Where PagePath = '" + RelativeURL + "'";
System.Data.SqlClient.SqlCommand CMD = new System.Data.SqlClient.SqlCommand(SQLSelect,DataBaseConnection);
System.Data.SqlClient.SqlDataReader RS = CMD.ExecuteReader();
if (RS.HasRows)
{
RS.Read();
pageTitle = RS.GetString(1);
pageClass = RS.GetString(2);
PageCount = RS.GetInt32(3) + 1; //this line here is the pain
PageSecureDB = RS.GetString(4);
PageMaintDB = RS.GetString(5);
if (PageSecureDB.ToLower() != "yes")
{
pageSecure = false;
}
if (PageMaintDB.ToLower() != "yes")
{
pageMaintenance = false;
}
RS.Close();
SQLSelect = "UPDATE PageData Set HitCount = " + PageCount.ToString() + " Where PagePath = '" + RelativeURL + "'";
CMD = new System.Data.SqlClient.SqlCommand(SQLSelect,DataBaseConnection);
CMD.ExecuteNonQuery();
}
else
{
RS.Close();
SQLSelect = "INSERT INTO PageData (PagePath,PageTitle,PageClass,HitCount,SecurePage,Maintenance) VALUES ('" + RelativeURL + "','" + pageTitle + "','" + pageClass + "'," + PageCount.ToString() + ",'yes','yes')";
CMD = new System.Data.SqlClient.SqlCommand(SQLSelect,DataBaseConnection);
CMD.ExecuteNonQuery();
}