12/20/2006

dvbbs 7.1 access版到sql版的转换

一、声明

本文意在探索技术,增强论坛功能,无侵害他人谋取利益之念,所讨论的软件均由动网免费提供。不得将本文所述之方法用于商业目的,如果使用不当,侵犯他人合法利益或者对他人造成其它损害,本人概不负责。

二、主旨

众所周知,access数据库有众多的缺陷,如:不支持多处理器,不能并行查询,查询效率低下,文件最大2GB,全文检索效率低下,自身无法实现自动备份,不能实时打开数据库,安全性差等等,而这些问题在sql server 2000中均不存在。
本人经过探索发现,dvbbs7.1.0 access版只要增加4个存储过程就能使用sql 2000数据库,轻松把dvbbs7.1.0 access版改造为dvbbs7.1.0 sql版,如此我们就能享受sql server 2000带来的优越特性了。

三、准备

dvbbs7.1.0_ac.exe,dvbbs7.1.0_ac_up.exe,请从动网下载。

四、转换

1、access到sql server
把数据从access转换到sql server中时,应使用access中的升迁向导来未完成,此时不能使用sql server的企业管理器,并要删除sql server 中对应的表。
升迁时,要建立到sql server的odbc数据源连接,不使用时间戳功能。
2、sql server到access
把数据从sql server转换到access中时,应使用sql server的企业管理器来完成,此时不要用access的获取外部数据。
转换时,access中要有对应版本的表结构,如:把sql server中的dvbbs7.0.0sp2数据转换到access时,可以把dvbbs7.0.0sp2 access版的数据库dvbbs7.mdb中所有表的数据清除,但保留表结构。

五、全新安装

1、使用(四、转换,1、access到sql server)的方法,把dvbbs7.1.0_ac.exe中的dvbbs7.mdb转换到sql server。
2、用(八、脚本)提供的脚本,使用查询分析器在sql server中创建所必须的4个存储过程。
3、在conn.asp中建立到sql server的连接。
4、使用dvbbs7.1.0_ac_up.exe中的cleancache.asp,清空缓存。

六、升级安装

1、使用(四、转换,2、sql server到access)的方法,把sql server中dvbbs7.0.0sp2的数据转换到dvbbs7.mdb中。
2、使用dvbbs7.1.0_ac_up.exe中的update.asp对dvbbs7.mdb升级。
3、使用(四、转换,1、access到sql server)的方法,把dvbbs7.mdb转换到sql server中。
4、用(八、脚本)提供的脚本,使用查询分析器在sql server中创建所必须的4个存储过程。
5、在conn.asp中建立到sql server的连接。
6、使用dvbbs7.1.0_ac_up.exe中的cleancache.asp,清空缓存。

七、说明

1、本文未详述的地方参见dvbbs7.1.0 access版的安装和升级说明。
2、odbc数据源的建立,查询分析器和企业管理器的使用,如果不会,请参见有关使用方法。

八、脚本
请使用明文版的脚本,加密版的有Bug。
复制到查询分析器中执行。
----------4个存储过程的sql脚本,本虚线不包含在脚本中---------------
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Dv_TSQL]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[Dv_TSQL]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Dv_loadSetup]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[Dv_loadSetup]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[dv_list]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[dv_list]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[dv_toplist]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[dv_toplist]
GO

SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO


CREATE PROCEDURE [Dv_TSQL]

@tsql varchar(500)

AS
exec(@tsql)

GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO

CREATE PROCEDURE [Dv_loadSetup]
AS
Select * from [Dv_setup]

GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS OFF
GO


CREATE PROCEDURE [dv_list]

@boardid int=1,
@pagenow int=1,
@pagesize int=1,
@tl int=0,
@topicmode int=0,
@totalrec int output


AS
set nocount on
declare @int_topnum int
declare @int_timenum int
declare @var_times varchar(5000)

if @pagenow>1
if @topicmode>0
begin
select @int_timenum=(@pagenow-1)*@pagesize
set rowcount @int_timenum
select @var_times=lastposttime from Dv_Topic where boardID=@boardID and istop = 0 and mode=@topicmode ORDER BY lastposttime desc

set rowcount @pagesize
select TopicID,boardid,title,postusername,postuserid,dateandtime,child,hits,votetotal,lastpost,lastposttime,istop,isvote,isbest,locktopic,Expression,TopicMode,Mode,GetMoney,GetMoneyType,UseTools,IsSmsTopic from dv_topic where boardID=@boardID and istop = 0 and mode=@topicmode and lastposttime < @var_times ORDER BY lastposttime desc

set nocount off
return
end
else
begin
select @int_timenum=(@pagenow-1)*@pagesize
set rowcount @int_timenum
select @var_times=lastposttime from Dv_Topic where boardID=@boardID and istop = 0 ORDER BY lastposttime desc

set rowcount @pagesize
select TopicID,boardid,title,postusername,postuserid,dateandtime,child,hits,votetotal,lastpost,lastposttime,istop,isvote,isbest,locktopic,Expression,TopicMode,Mode,GetMoney,GetMoneyType,UseTools,IsSmsTopic from dv_topic where boardID=@boardID and istop = 0 and lastposttime < @var_times ORDER BY lastposttime desc

set nocount off
return
end

else
if @topicmode>0
begin
set rowcount @pagesize
select TopicID,boardid,title,postusername,postuserid,dateandtime,child,hits,votetotal,lastpost,lastposttime,istop,isvote,isbest,locktopic,Expression,TopicMode,Mode,GetMoney,GetMoneyType,UseTools,IsSmsTopic from Dv_topic where boardID=@boardid and istop = 0 and mode=@topicmode ORDER BY lastposttime desc
end
else
begin
set rowcount @pagesize
select TopicID,boardid,title,postusername,postuserid,dateandtime,child,hits,votetotal,lastpost,lastposttime,istop,isvote,isbest,locktopic,Expression,TopicMode,Mode,GetMoney,GetMoneyType,UseTools,IsSmsTopic from Dv_topic where boardID=@boardid and istop = 0 ORDER BY lastposttime desc
end


GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS OFF
GO

CREATE PROCEDURE [dv_toplist]

@pagenow int ,
@pagesize int ,
@reture_value int output,
@intUserRecordCount int output

as

declare @intBeginID int
declare @intEndID int
declare @intPageCount int
declare @intRowCount int


set nocount on


select @intUserRecordCount = count(*) from [dv_user]
if (@intUserRecordCount = 0)
set @reture_value =0

if (@pagenow - 1) * @pagesize > @intUserRecordCount
set @reture_value =1


set @intRowCount = (@pagenow - 1) * @pagesize + 1

set rowcount @intRowCount
select @intBeginID = userid from [dv_user] order by userid desc


set @intRowCount = @pagenow * @pagesize

set rowcount @intRowCount
select @intEndID = userid from [dv_user] order by userid desc


set rowcount 0
set nocount off

select username,useremail,userclass,UserIM,UserPost,JoinDate,userwealth,userid from [dv_user] where userid between @intEndID and @intBeginID order by userid desc
return(@@rowcount)


GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
----------4个存储过程的sql脚本,本虚线不包含在脚本中---------------

0 comments: