User-1283384789 posted
Hi,
I have this code that counts # of hits. It works, but i noticed that if you go for exmaple to item # 2 it shows 5 hits, then when i go to item #3 and return back to item # 2 it shows 7 hits instead of 6.
This is my code:
protected void DataList3_Load(object sender, EventArgs e)
{
Label hits = DataList3.FindControl("hits") as Label;
string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\\Orozje-Reloading-Center.mdb";
OleDbConnection conn = new OleDbConnection(connectionString);
conn.Open();
OleDbCommand cmd = new OleDbCommand();
cmd.Connection = conn;
cmd.CommandText = "SELECT * FROM [NABOJI_POLNITVE] WHERE PID = ?";
cmd.CommandText = "UPDATE NABOJI_POLNITVE SET hits = hits + 1";
cmd.Parameters.Add("@hits", OleDbType.Integer).Value = hits;
cmd.ExecuteNonQuery();
conn.Close();
}
Not sure what to change so it will show corect count.
Thanks