Last post Jun 16, 2009 07:39 AM by Urko
Jun 16, 2009 05:22 AM|Urko|LINK
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);
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;
Not sure what to change so it will show corect count.
Jun 16, 2009 06:50 AM|suthish nair|LINK
put breakpoint and debug the code line by line, vr it gets fails..
Jun 16, 2009 07:39 AM|Urko|LINK
i tried debug it but i didnt get any error messages. Problem is that in my case it counts a hit on item #2 even though i was on item #3.