Facebook之类的查询asp.net网站 [英] facebook like query for asp.net website
本文介绍了Facebook之类的查询asp.net网站的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好
我想在我的网站上使用Facebook之类的查询..
我有一个电子商务网站.这个网站有很多产品.
当用户单击产品然后显示赞"按钮时.
当用户通过自己的电子邮件ID单击赞"按钮时,我想做的事情是产品应与特定ID相似.
提前非常感谢您
hello
I want to use facebook like query for my website..
I have an e-commerce web website. and this website has many products.
When a user clicks on a product and then are show a ''like'' button.
I want to do when user click on like button by his own email id then product should be like by particular id.
Thank you very much in advance
推荐答案
创建tabke,例如
Create tabke like
id int
likedis bit
productid int
userid varchar(150)
对(productid,userid)进行唯一约束
创建存储过程,如
make unique constraints on (productid,userid)
Create stored procedure like
ALTER PROCEDURE [dbo].[inslike]
@aid int,
@userid varchar(150)
as
BEGIN
begin try
BEGIN TRANSACTION
insert into tbllike (likedis,productid,userid) values(1,@aid,@userid);
update tblProduct set like1=like1+1 where ID=@aid;
Commit
end try
begin catch
ROLLBACK
end catch
END
在像buttonclick
上
on like buttonclick
SqlCommand cmd = new SqlCommand();
cmd.Connection = GetConnection();
cmd.CommandText = "inslike";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@aid", int.Parse(e.CommandArgument.ToString()));
cmd.Parameters.AddWithValue("@userid", Session["userid"].ToString());
cmd.ExecuteNonQuery();
cmd.Connection.Close();
getData();
这篇关于Facebook之类的查询asp.net网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文