User932259438 posted
Hi,
My code:
var obj = new
{
data = new
{
post_info = new
{
ID = "1",
UserId = HttpContext.Current.Request.Cookies["UserId"],
date = DateTime.Now,
imgpath = "none",
videopath = "none",
likecount = "1",
sharecount = "1",
likeperson = new { ID= "likeperson1" },
},
}
};
var post = JsonConvert.SerializeObject(obj);
string conStr = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
using (SqlConnection con = new SqlConnection(conStr))
{
using (SqlCommand cmd = new SqlCommand("INSERT INTO tbl_Posts VALUES(@Post)"))
{
cmd.CommandType = CommandType.Text;
cmd.Parameters.AddWithValue("@Post", post);
cmd.Connection = con;
con.Open();
cmd.ExecuteNonQuery();
con.Close();
}
}
This code is on Button1 and insert correct.
In Button2 I need add another likeperson in db. I need to find ID=1 and insert new likeperson:
likeperson = new { ID= "likeperson1" },
likeperson = new { ID= "likeperson2" }, - its new data-
Please help.