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 MohapatraPosted Jan 2, 2016, 3:27 AM
Secondly check your connection string which database server you pointing to.
Make sure that your code executed properly with out any exception.
MsDotNet rajaPosted Jan 2, 2016, 3:42 AM
MsDotNet rajaPosted Jan 2, 2016, 3:17 AM
Manas MohapatraPosted Jan 2, 2016, 1:58 AM