数据库记录更新不了
xawnu 2009-07-13 11:18:09 ASP程序,用来统计站点访问页面,每个商家有个单独的ID(VisSmemberid )作为主键
用下面程序判断,思路是这样,如果数据库表里没有这个商家的记录就添加一个商家记录,
sitememberid这个是作为会话调用判断商家ID的
protype,shopstype ,bustype,这个几个表示商家页面主页面,产品页面,和购买页面
如果已经包含这个商家记录的话,在这条记录上更新,但是测试过后,添加可以,但是更新记录通不过
,测试将else下面的语句放到判断的上半部分的时候,可以添加没有的记录,也可以更新,但是只能更
新数据库表里的第一条记录,其他记录更新不了。
<%
dim countrs,bustype,shopstype,protype
protype = request.QueryString("protype")
shopstype = request.QueryString("shopstype")
bustype = request.QueryString("bustype")
sitememberid = request.QueryString("sitememberid")
set countrs = server.CreateObject("adodb.recordset")
countrs.open "select * from [Visitz]",conn,1,3
if VisSmemberid <> sitememberid then
countrs.addnew
countrs("VisSmemberid")=sitememberid
if session("fortunememberid") <> ""then
countrs("VisFmemberid")=session("fortunememberid")
countrs("VisType")=1 '0匿名 1会员
else
countrs("VisType")=0
end if
if bustype = 1 then
countrs("VisBus")=1
end if
if protype = 1 then
countrs("VisPro")=1
end if
if shopstype = 1 then
countrs("VisShops")=1
end if
else
if session("fortunememberid") <> ""then
countrs("VisFmemberid")=session("fortunememberid")
countrs("VisType")=1 '0匿名 1会员
else
countrs("VisType")=0
end if
if bustype = 1 then
countrs.open "select * from [Visitz] where VisSmemberid="&request("sitememberid"),conn,1,3
countrs("VisBus")=rs("VisBus")+1
countrs.update
'countrs("VisBus")=1
end if
if protype = 1 then
countrs.open "select * from [Visitz] where VisSmemberid="&request("sitememberid"),conn,1,3
countrs("VisPro")=rs("VisPro")+1
countrs.update
'countrs("VisPro")=1
end if
if shopstype = 1 then
countrs.open "select * from [Visitz] where VisSmemberid="&request("sitememberid"),conn,1,3
countrs("VisShops")=rs("VisShops")+1
countrs.update
'countrs("VisShops")=1
end if
end if
countrs("VisIP")=request.ServerVariables("REMOTE_ADDR")
countrs("VisDate")=date()
countrs.update
countrs.close
set countrs = nothing
%>