- 积分
- 73549
- 明经币
- 个
- 注册时间
- 2001-6-7
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
动网的7.1版开放了SQL版本供大家免费使用,但现在已经是8.3版本了,怎么才能也用8.3版本的SQL版。由于8.3版本比较新,D版肯定是找不到的,但D版的8.2版是找得到的,所以大家可以升级到8.3版的SQL后,用8.2版的储存过程,再经过以下改造就可以用了。1.dispbbs.asp改成:- If IsSqlDataBase=1 And IsBuss=1 And Skin=0 Then
- 'mccad edit 将8.3存储方式改成8.2,因为8.3SQL版还没有D版出现
- Set Cmd = Dvbbs.iCreateObject("ADODB.Command")
- Set Cmd.ActiveConnection=conn
- Cmd.CommandText="dv_dispbbs"
- Cmd.CommandType=4
- Cmd.Parameters.Append cmd.CreateParameter("@boardid",3)
- Cmd.Parameters.Append cmd.CreateParameter("@rootid",3)
- Cmd.Parameters.Append cmd.CreateParameter("@pagenow",3)
- Cmd.Parameters.Append cmd.CreateParameter("@pagesize",3)
- Cmd.Parameters.Append cmd.CreateParameter("@totalusetable",200,1,20)
- Cmd("@boardid")=Dvbbs.BoardID
- Cmd("@rootid")=ReplyID
- Cmd("@pagenow")=G_CurrentPage
- Cmd("@pagesize")=G_ItemsPerPage
- Cmd("@totalusetable")=TotalUsetable
- Set Rs=Cmd.Execute
- If Not Rs.EoF Then
- G_ItemList=Rs.GetRows(-1)
- Else
- Dvbbs.AddErrCode(29)
- End If
- Rs.close()
- Set Rs=Nothing
- Set Cmd = Nothing
- ' Dim mypage
- ' Set mypage=new Pager
- ' 'If Not IsObject(Conn) Then ConnectionDatabase
- ' mypage.getconn=conn '得到数据库连接
- ' mypage.pagesize=G_ItemsPerPage '定义分页每一页的记录数
- ' mypage.TableName=TotalUsetable '要查询的表名
- ' mypage.Tablezd=sqlfields
- ' mypage.KeyName="announceid"
- ' mypage.OrderType=0
- ' mypage.PageWhere=sqlfieldswhere
- ' mypage.GetStyle =1
- ' Set Rs=mypage.getrs()
- ' If Not Rs.EoF Then
- ' G_ItemList=Rs.GetRows(-1)
- ' Else
- ' Rs.close():Set Rs=Nothing:Dvbbs.AddErrCode(29)
- ' End If
- ' Rs.close():Set Rs=Nothing
- ' 'Set Cmd = Nothing
- Else
2.index.asp改成:- If IsSqlDataBase=1 And IsBuss=1 Then
- 'mccad edit 将8.3存储方式改成8.2,因为8.3SQL版还没有D版出现
- Set Cmd = Dvbbs.iCreateObject("ADODB.Command")
- Set Cmd.ActiveConnection=conn
- Cmd.CommandText="dv_TopicList"
- Cmd.CommandType=4
- Cmd.Parameters.Append cmd.CreateParameter("@boardid",3)
- Cmd.Parameters.Append cmd.CreateParameter("@pagenow",3)
- Cmd.Parameters.Append cmd.CreateParameter("@pagesize",3)
- Cmd.Parameters.Append cmd.CreateParameter("@topicmode",3)
- Cmd.Parameters.Append cmd.CreateParameter("@inConditions",200,1,250)
- Cmd.Parameters.Append cmd.CreateParameter("@inOrder",3)
- Cmd.Parameters.Append cmd.CreateParameter("@inSort",3)
- Cmd.Parameters.Append cmd.CreateParameter("@totalrec",3,2,4)
-
- Cmd("@boardid")=Dvbbs.BoardID
- Cmd("@pagenow")=Page
- Cmd("@pagesize")=Cint(Dvbbs.Board_Setting(26))
- Cmd("@topicmode")=TopicMode
- Cmd("@inConditions")=SQLQuery
- Cmd("@inOrder")=OrderId
- Cmd("@inSort")=SortId
-
- Set Rs=Cmd.Execute
- If Not Rs.EoF Then
- Topic=Rs.GetRows(-1)
- Else
- Topic=Null
- End If
- Rs.close()
- Set Rs=Nothing
- Count = Cmd("@totalrec")
- Set Cmd = Nothing
- 'Dim mypage
- 'Set mypage=new Pager
- 'mypage.getconn=conn '得到数据库连接
- 'mypage.pagesize=Cint(Dvbbs.Board_Setting(26)) '定义分页每一页的记录数
- 'mypage.TableName="Dv_Topic" '要查询的表名
- 'mypage.Tablezd=sqlfields
- 'mypage.KeyName=OrderField
- 'mypage.OrderType=OrderType
- 'mypage.PageWhere=sqlfieldswhere
- 'mypage.GetStyle =1
- 'Set Rs=mypage.getrs()
- 'If Not (Rs.EoF And Rs.Bof) Then
- ' Topic=Rs.GetRows(-1)
- 'Else
- ' Topic=Null
- 'End If
- 'Count = mypage.int_totalRecord
- 'Rs.close()
- 'Set Rs=Nothing
- Else
-
3.dv_dispbbs 储存过程:- CREATE PROCEDURE [dv_Dispbbs]
- @boardid int=0,
- @rootid int=0,
- @pagenow int=1,
- @pagesize int=1,
- @totalusetable nvarchar(20)='dv_bbs1'
- AS
- set nocount on
- declare @int_top int
- declare @int_begin int
- declare @str_sql nvarchar(500)
-
- if @pagenow>1
- begin
- select @int_top=(@pagenow-1)*@pagesize
- SET @str_sql ='SELECT @int_begin = Max(announceid ) FROM (Select Top '+str(@int_top)+' announceid From '+@totalusetable+' where RootID='+str(@rootid)+' and Boardid='+str(@boardid)+' Order By Announceid ) as t'
-
- exec sp_executesql @str_sql,N'@int_begin int output ',@int_begin output
-
- set @str_sql='select AnnounceID,UserName,Topic,dateandtime,body,Expression,ip,RootID,signflag,isbest,PostUserid,layer,isagree,GetMoneyType,IsUpload,Ubblist,LockTopic,GetMoney,UseTools,PostBuyUser,ParentID,FlashId From '+@totalusetable+' where RootID='+str(@rootid)+' and announceid>'+str(@int_begin)+' and Boardid='+str(@boardid)+' Order By Announceid'
- set rowcount @pagesize
- exec sp_executesql @str_sql
- set nocount off
- return
- end
- else
- begin
- set rowcount @pagesize
- set @str_sql='Select AnnounceID,UserName,Topic,dateandtime,body,Expression,ip,RootID,signflag,isbest,PostUserid,layer,isagree,GetMoneyType,IsUpload,Ubblist,LockTopic,GetMoney,UseTools,PostBuyUser,ParentID,FlashId From '+@totalusetable+' where RootID='+str(@rootid)+' and Boardid='+str(@boardid)+' Order By Announceid'
- exec sp_executesql @str_sql
- return
- end
- GO
复制代码 4.dv_TopicList储存过程:CREATE PROCEDURE [dv_TopicList]
@boardid int=1,
@pagenow int=1, --当前页数
@pagesize int=1, --定义每页面帖子数目
@topicmode int=0, --专题
@inConditions varchar(250)=' ',
@inOrder int=0,
@inSort int=0,
@totalrec int output --SET @TotalRec=@@ROWCOUNT
AS
SET nocount on
DECLARE @int_topnum int
DECLARE @int_timenum int
DECLARE @var_times varchar(5000)
DECLARE @OrderField varchar(20)
DECLARE @SortStr varchar(5)
DECLARE @strSQL nvarchar(4000)
DECLARE @Compare varchar(1)
DECLARE @nRet int
Declare @Compare1 nvarchar(20)
IF @inOrder=0
SET @OrderField='LastPostTime'
ELSE IF @inOrder=1
SET @OrderField='TopicId'
ELSE IF @inOrder=2
SET @OrderField='hits'
ELSE IF @inOrder=3
SET @OrderField='child'
ELSE
SET @OrderField='LastPostTime'
IF @inSort=0
BEGIN
SET @SortStr='DESC'
SET @Compare = '<'
Set @Compare1='Min'
END
ELSE
BEGIN
SET @SortStr='ASC'
SET @Compare = '>'
Set @Compare1='Max'
END
IF @pagenow>1
IF @topicmode>0
BEGIN
SELECT @int_timenum=(@pagenow-1) * @pagesize
--SET ROWCOUNT @int_timenum
SET @strSQL='SELECT @var_times ='+@Compare1+'(' + @OrderField + ') FROM (Select Top '+str(@int_timenum)+' ' + @OrderField + ' From Dv_Topic WHERE mode=@3 And boardID=@2 AND istop = 0 ' + @inConditions + 'ORDER BY ' + @OrderField + ' ' + @SortStr +') as t'
EXEC sp_executesql @strSQL,N'@var_times varchar(5000) output,@2 int,@3 int',@var_times output,@2=@boardID,@3=@topicmode
SET ROWCOUNT @pagesize
SET @strSQL='SELECT TopicID,boardid,title,postusername,postuserid,dateandtime,child,hits,votetotal,lastpost,lastposttime,istop,isvote,isbest,locktopic,Expression,TopicMode,Mode,GetMoney,GetMoneyType,UseTools,IsSmsTopic,HideName FROM dv_topic WHERE mode=@3 AND boardID=@2 AND istop = 0 AND ' + @OrderField + @Compare + ' @1 ' + @inConditions + ' ORDER BY ' + @OrderField + ' ' + @SortStr
EXEC sp_executesql @strSQL,N'@1 varchar(5000),@2 int,@3 int',@1=@var_times,@2=@boardID,@3=@topicmode
SET @strSQL='SELECT @nRet=COUNT(1) FROM Dv_Topic WHERE mode=@3 AND boardID=@2 AND istop=0 ' + @inConditions
EXEC sp_executesql @strSQL,N'@nRet int output , @2 int,@3 int',@nRet output ,@2=@boardID,@3=@topicmode
SELECT @totalrec=@nRet
SET nocount OFF
RETURN
END
ELSE --@topicmode
BEGIN
SELECT @int_timenum=(@pagenow-1) * @pagesize
--SET ROWCOUNT @int_timenum
--SET @strSQL='SELECT @var_times=' + @OrderField + ' FROM Dv_Topic WHERE boardID=@2 AND istop=0 ' + @inConditions +' ORDER BY ' + @OrderField + ' ' + @SortStr
SET @strSQL='SELECT @var_times ='+@Compare1+'(' + @OrderField + ') FROM (Select Top '+str(@int_timenum)+' ' + @OrderField + ' From Dv_Topic WHERE boardID=@2 AND istop=0 ' + @inConditions +' ORDER BY ' + @OrderField + ' ' + @SortStr +') as t'
EXEC sp_executesql @strSQL,N'@var_times varchar(5000) output,@2 int',@var_times output,@2=@boardID
SET ROWCOUNT @pagesize
SET @strSQL='SELECT TopicID,boardid,title,postusername,postuserid,dateandtime,child,hits,votetotal,lastpost,lastposttime,istop,isvote,isbest,locktopic,Expression,TopicMode,Mode,GetMoney,GetMoneyType,UseTools,IsSmsTopic,HideName FROM dv_topic WHERE boardID=@2 AND istop = 0 AND ' + @OrderField + @Compare + ' @1 ' + @inConditions + ' ORDER BY ' + @OrderField + ' ' + @SortStr
EXEC sp_executesql @strSQL,N'@1 varchar(5000),@2 int',@1=@var_times,@2=@boardID
SET @strSQL='SELECT @nRet=COUNT(1) FROM Dv_Topic WHERE boardID=@2 AND istop=0 ' + @inConditions
EXEC sp_executesql @strSQL,N'@nRet int output ,@2 int',@nRet output , @2=@boardID
SELECT @totalrec=@nRet
SET nocount OFF
RETURN
END
ELSE --pagenow
IF @topicmode>0
BEGIN
SET ROWCOUNT @pagesize
SET @strSQL='SELECT TopicID,boardid,title,postusername,postuserid,dateandtime,child,hits,votetotal,lastpost,lastposttime,istop,isvote,isbest,locktopic,Expression,TopicMode,Mode,GetMoney,GetMoneyType,UseTools,IsSmsTopic,HideName FROM Dv_topic WHERE mode=@3 AND boardID=@2 AND istop =
0 ' + @inConditions + ' ORDER BY ' + @OrderField + ' ' + @SortStr
EXEC sp_executesql @strSQL,N'@2 int,@3 int',@2=@boardID,@3=@topicmode
SET @strSQL='SELECT @nRet=COUNT(1) FROM Dv_Topic WHERE mode=@3 And boardID=@2 AND istop=0 ' + @inConditions
EXEC sp_executesql @strSQL,N'@nRet int output,@2 int,@3 int',@nRet output,@2=@boardID,@3=@topicmode
SELECT @totalrec=@nRet
END
ELSE --topicmode
BEGIN
SET ROWCOUNT @pagesize
SET @strSQL='SELECT TopicID,boardid,title,postusername,postuserid,dateandtime,child,hits,votetotal,lastpost,lastposttime,istop,isvote,isbest,locktopic,Expression,TopicMode,Mode,GetMoney,GetMoneyType,UseTools,IsSmsTopic,HideName FROM Dv_topic WHERE boardID=@2 AND istop=0 ' + @inConditions + ' ORDER BY ' + @OrderField + ' ' + @SortStr
EXEC sp_executesql @strSQL,N'@2 int',@2=@boardID
SET @strSQL='SELECT @nRet=COUNT(TopicID) FROM Dv_Topic WHERE boardID=@2 AND istop=0 ' + @inConditions
EXEC sp_executesql @strSQL,N'@nRet int output,@2 int',@nRet output,@2=@boardID
SELECT @totalrec=@nRet
END
/****** 对象: StoredProcedure [dv_disp] 脚本日期: 02/26/2008 15:59:30 ******/
SET ANSI_NULLS ON
GO |
|