请大家帮忙仿写一下这段写入数据库的代码
Function ClassUpdateCount(sortid,stype)Dim rscount,Parentstr
On Error Resume Next
Set rscount = NewAsp.Execute("SELECT ClassID,Parentstr FROM [NC_Classify] WHERE ChannelID=" & ChannelID & " And ClassID=" & CLng(sortid))
If Not (rscount.BOF And rscount.EOF) Then
Parentstr = rscount("Parentstr") &","& rscount("ClassID")
If CInt(stype) = 1 Then
NewAsp.Execute ("UPDATE [NC_Classify] SET ShowCount=ShowCount+1,isUpdate=1 WHERE ChannelID="& ChannelID &" And ClassID in (" & Parentstr & ")")
ElseIf stype = 2 Then
NewAsp.Execute ("UPDATE [NC_Classify] SET isUpdate=1 WHERE ChannelID="& ChannelID &" And ClassID in (" & Parentstr & ")")
Else
NewAsp.Execute ("UPDATE [NC_Classify] SET ShowCount=ShowCount-1,isUpdate=1 WHERE ChannelID="& ChannelID &" And ClassID in (" & Parentstr & ")")
End If
End If
Set rscount = Nothing
End Function
上面你这段是范例,通过录入文章后开始对NC_Classify表中的ShowCount字段进行写入。现在我需要仿写一段:
Function AddUserPointNum(username,stype)
Dim rscount,fawen
On Error Resume Next
Set rscount = NewAsp.Execute("SELECT ID,fawen FROM [NC_Admin] WHERE username=" & username & " And ID=" & CLng(id))
If Not (rscount.BOF And rscount.EOF) Then
fawen = rscount("fawen") &","& rscount("ID")
If CInt(stype) = 1 Then
NewAsp.Execute ("UPDATE [NC_Admin] SET fawen=fawen+1,isUpdate=1 WHERE username="& username &"")
ElseIf stype = 2 Then
NewAsp.Execute ("UPDATE [NC_Admin] SET isUpdate=1 WHERE username="& username &"")
Else
NewAsp.Execute ("UPDATE [NC_Admin] SET fawen=fawen-1,isUpdate=1 WHERE ID="& ChannelID &"")
End If
End If
Set rscount = Nothing
End Function
我的想法是通过录入文章完毕后即向NC_Admin表中的fawen字段进行写入。由于是新手,对asp的语法都还不熟悉,恳请大家指教,本人万分感谢!!!