if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[insertpic]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[insertpic]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[showpage]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[showpage]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[picpath]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[picpath]
GO
CREATE TABLE [dbo].[picpath] (
[id] [int] IDENTITY (1, 1) NOT NULL ,
[path] [varchar] (100) COLLATE Chinese_PRC_CI_AS NULL
) ON [PRIMARY]
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS OFF
GO
--感化:拔出纪录
CREATE PROCEDURE [insertpic]
(
--途径--
@path varchar(100)
)
AS
insert picpath(path) values(@path)
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS OFF
GO
CREATE PROCEDURE showpage
----页码
@PageNum int
AS
SET NOCOUNT ON
declare
@pagecount int,
@iFrom int,
@iRowCount int,
@dpicid int
----盘算该页肇端的偏移量
if @PageNum <= 0
set @PageNum = 1
set @iFrom = 10 * (@PageNum - 1) + 1
----判别传入的页码是不是无效
select @iRowCount = count(id) from picpath ----获得图片数
set @PageCount = @iRowCount / 10 ----盘算图片页数
if @iRowCount %10> 0
set @PageCount = @PageCount + 1
if @iRowCount < @iFrom
begin
set @iFrom = @iRowCount - 10
end
if @iFrom<0
select @iFrom=0
set rowcount @iFrom
select @dpicid = id from picpath order by id desc
set rowcount 0
----获得图片列表
select @pagecount as pagecount
select top 10 * from picpath Where id <= @dpicid order by id desc
SET NOCOUNT off
SP_END:
select @pagecount as pagecount
SET NOCOUNT off
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
'# --------------------------------------------------------------------------
'# 函数:getFileExtName
'# 描写:取得文件是不是为图片文件
'# 参数:--fName
'# 前往:--true or false
'# 作者:cxb
'# 日期:2003-9-26
'#--------------------------------------------------------------------------
function getFileExtName(fName)
if instr(fname,".gif") or instr(fname,".GIF") or instr(fname,".jpg") or instr(fname,".JPG") or instr(fname,".bmp") or instr(fname,".BMP") then
getFileExtName=true
else
getFileExtName=false
end if
end function