Hi, I have a column called Likes in my db, and in repeater i have a button, if a user clicks on the button the value in db should increase by +1 on every click and the button should display the number of likes in count(as 32 likes).
asp code:
C# code:
protected void rptCustomers_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
using (MySqlConnection con = new MySqlConnection(connString))
{
using (MySqlCommand cmd = new MySqlCommand("UPDATE articles SET Likes = Likes+1 WHERE Pid=" + Pid, con))
{
using (con)
{
con.Open();
cmd.ExecuteNonQuery();
con.Close();
}
}
}
}
Please correct my code, thanx in advance.

Manas MohapatraRank #182 · 13.2K reputationPosted Jan 1, 2016, 10:27 PM EST
Secondly check your connection string which database server you pointing to.
Make sure that your code executed properly with out any exception.
Manas MohapatraRank #182 · 13.2K reputationPosted Jan 1, 2016, 8:58 PM EST
MsDotNet raja11 reputationPosted Jan 1, 2016, 10:42 PM EST
MsDotNet raja11 reputationPosted Jan 1, 2016, 10:17 PM EST