'*************************************************************************************
'函数名:GetID
'作 用:生成文章,图片或下载等的唯一ID
'参 数:ChannelID--频道ID
'alluse 2007/1/9
'*************************************************************************************
Public Function GetID(ChannelID)
On Error Resume Next
Dim RSC, TableNameStr
Set RSC=Server.CreateObject("ADODB.RECORDSET")
Select Case ChannelID
Case 1
TableNameStr = "Select top 1 ID From KS_Article order by ID desc"
Case 2
TableNameStr = "Select top 1 ID From KS_Photo order by ID desc"
Case 3
TableNameStr = "Select top 1 ID From KS_DownLoad order by ID desc"
Case 4
TableNameStr = "Select top 1 ID From KS_Flash order by ID desc"
End Select
RSC.Open TableNameStr, Conn, 1, 1
If RSC.EOF Or RSC.BOF Then:GetID=1:Else:GetID=RSC("ID")+1:End If
RSC.Close:Set RSC = Nothing
End Function
调用 KSCMS.GetID(频道ID)
如在Admin_Article.asp里下面这样用,那么我们的NewsID等于ID了。
'文章ID
IF Action="Add" Then
NewsID = KSCMS.GetID(1)
初学ASP函数,大家看看有没有不妥当的,恳请指正。