Defragmenting disk files with ASP

Source: Internet
Author: User
Tags date count insert rowcount
There are too many files in the machine, so it needs to be sorted out.

This article to organize the picture file for example, give us a little thought
Code's operating environment: Iis5.0+sql server2000
Database scripts:

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] (MB) COLLATE chinese_prc_ci_as NULL
) on [PRIMARY]
Go

SET QUOTED_IDENTIFIER OFF
Go
SET ansi_nulls off
Go

--function: Inserting records
CREATE PROCEDURE [Insertpic]
(
--The path--
@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

/*
' # Process: showpage
' # Description: Used to record set paging
' # Parameter:-pagenum (page number)
' # returns:-two recordsets, the first Recordset contains two fields (total pages), and the second Recordset returns the data to the program to display for the database
' # Author: zhengs
' # Date: 2002-08-27

*/

CREATE PROCEDURE ShowPage
----page number
@PageNum int
As
SET NOCOUNT on
Declare
@pagecount int,
@iFrom int,
@iRowCount int,
@dpicid int



----Calculate the offset from the beginning of the page
If @PageNum <= 0
Set @PageNum = 1

Set @iFrom = ten * (@PageNum-1) + 1


----Determine if the incoming page number is valid
Select @iRowCount = count (id) from Picpath----get number of pictures
Set @PageCount = Count the number of pages of a picture @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

----Get a picture list
Select @pagecount as PageCount
Select Top * from Picpath Where ID <= @dpicid an 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

Searching and storing to a database
Search.asp

<% @LANGUAGE = "VBSCRIPT"%>
<%
'***********************************************************************************

' File name ...: search.asp
"Author ...: Cxb."
"Description ...: Search and store to database".
' Pay attention to ....:
Copyright (c), NetDragon Software, and so on .....
' Modify record ...: Time personnel notes
' --------- ------- -------------------------------------------
' 2003-09-26 Chen Xingba Create file

'***********************************************************************************
server.scripttimeout=500
Dim a,b
' Detection Time parameter
A=timer
Dim conn,strconn
Set conn = Server.CreateObject ("ADODB. Connection ")
strconn = "Provider=sqloledb;data source=127.0.0.1;initial catalog=search; User Id=sa; password=196881 "
Conn.Open strconn

Const adCmdStoredProc = &h0004
Const adParamInput = &h0001
Const adVarChar = 200

'# --------------------------------------------------------------------------
' # function: Getfileextname
' # Description: Get file as Picture file
' # parameter:--fname
' # return:--true or False
' # Author: cxb
' # Date: 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


'# --------------------------------------------------------------------------
' # function: Insertfilepath
' # Description: Insert path information into the database
' # parameter:--filename
' # return:--
' # Author: cxb
' # Date: 2003-9-26
'#--------------------------------------------------------------------------
function Insertfilepath (filename)
Dim



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.