?
??1
??2
'
author?:?jack
??3
'
date???:?2005-11-12
??4
'
email??:?jieck422@163.com
??5
'
文件存放解決辦法:
??6
'
把文件全部存放在saveFolder中,每個文件夾存放數量saveCount為2000個文件,用記錄集的id整除saveCount(id\saveCount)
??7
'
所得整數定為該文件所在目錄,文件名就是該id號。例如:saveFolder="F:\test",saveCount=2000,在表中有一記錄,其id為47(47\2000=0),該
??8
'
文件生成后存放的目錄為F:\test\0\47.shtml
??9
dim
?ID,myconn,zhli
?10
'
''''''''''''''''''''''''''''''''''''''在此添加過濾器
?11
ID
=
request.querystring(
"
id
"
)
?12
set
?myconn
=
new
?GetConnection
?13
if
?myconn.openRS(
"
select?a.E_name,a.E_date,a.E_zhouqi,a.E_changban,a.E_begindate,a.E_enddate,a.E_address,a.E_zhanguan,a.E_content,case?a.E_xingzhi?when?0?then?'國際展會'?when?1?then?'國內展會'?else?'國內展會'?end?as?xiangzhi,a.E_company,a.E_chengban,a.E_beizhu,b.[name],b.Phone,b.Fax,b.Email,b.Qymc?from?zhanhui?a,qiang_qyml?b?where?a.Exhib_ID=
"
&
ID
&
"
?and?a.gsid=b.id
"
)
=
false
?
then
?14
myconn.errMassege?
"
記錄集為空,請檢查ID是否正確!^_^
"
?15
response.end
?16
else
?17
set
?zhli
=
new
?ZhanHui_listinfo
?18
zhli.letModAddress
=
"
F:\test\li.shtml
"
?19
zhli.letSaveFolder
=
"
F:\test\
"
?20
zhli.letSaveCount
=
2000
?21
zhli.letContent
=
zhli.readContent
?22
zhli.replaceContent?
"
{$E_name$}
"
,myconn.rs(
0
)
?23
zhli.replaceContent?
"
{$E_date$}
"
,myconn.rs(
1
)
?24
zhli.replaceContent?
"
{$E_zhouqi$}
"
,myconn.rs(
2
)
?25
zhli.replaceContent?
"
{$E_changban$}
"
,myconn.rs(
3
)
?26
zhli.replaceContent?
"
{$E_begindate$}
"
,myconn.rs(
4
)
?27
zhli.replaceContent?
"
{$E_enddate$}
"
,myconn.rs(
5
)
?28
zhli.replaceContent?
"
{$E_address$}
"
,myconn.rs(
6
)
?29
zhli.replaceContent?
"
{$E_zhanguan$}
"
,myconn.rs(
7
)
?30
zhli.replaceContent?
"
{$E_content$}
"
,myconn.rs(
8
)
?31
zhli.replaceContent?
"
{$E_xingzhi$}
"
,myconn.rs(
9
)
?32
zhli.replaceContent?
"
{$E_company$}
"
,myconn.rs(
10
)
?33
zhli.replaceContent?
"
{$E_chengban$}
"
,myconn.rs(
11
)
?34
zhli.replaceContent?
"
{$E_beizhu$}
"
,myconn.rs(
12
)
?35
zhli.replaceContent?
"
{$linkman$}
"
,myconn.rs(
13
)
?36
zhli.replaceContent?
"
{$linkphone$}
"
,myconn.rs(
14
)
?37
zhli.replaceContent?
"
{$linkfax$}
"
,myconn.rs(
15
)
?38
zhli.replaceContent?
"
{$linkemail$}
"
,myconn.rs(
16
)
?39
zhli.replaceContent?
"
{$companyname$}
"
,myconn.rs(
17
)
?40
zhli.asp2html?zhli.makefilename(ID),zhli.getContent
?41
end
?
if
?42
?43
class?ZhanHui_listinfo
?44
?
'
文件生成類
?45
?
private
?modAddress,saveFolder,fso,ts,content,saveCount
?46
?
'
modAddress---------摸班地址
?47
?
'
saveFolder---------存放目錄
?48
?
'
content------------模版內容
?49
?
'
saveCount----------存放數量
?50
?
private
?
sub
?class_initialize()
'
類初始化
?51
?
set
?fso
=
Server.CreateObject(
"
SCRIPTING.FILESYSTEMOBJECT
"
)
?52
?
end?sub
?53
?54
?
public
?
property
?
let
?letSaveCount(str)
?55
?saveCount
=
str
?56
?
end?property
?57
?58
?
'
let?saveFolder
?59
?
public
?
property
?
let
?letSaveFolder(str)
?60
?saveFolder
=
str
?61
?
end?property
?62
?63
?
'
let?modAddress
?64
?
public
?
property
?
let
?letModAddress(str)
?65
?modAddress
=
str
?66
?
end?property
?67
?68
?
'
let?Content
?69
?
public
?
property
?
let
?letContent(str)
?70
?content
=
str
?71
?
end?property
?72
?
'
get?Content
?73
?
public
?
property
?
get
?getContent
?74
?getContent
=
content
?75
?
end?property
?76
?77
?
public
?
function
?makefilename(ID)
'
文件名以及路徑
?78
?foldername
=
ID
\
saveCount
?79
?
if
?
not
?fso.FolderExists(saveFolder
&
foldername)?
then
?80
?fso.createfolder(saveFolder
&
foldername)
?81
?
end
?
if
?82
?makefilename
=
saveFolder
&
foldername
&
"
\
"
&
ID
&
"
.shtml
"
?83
?
end?function
?84
?85
?
public
?
function
?readContent()
'
讀取摸班內容
?86
?
set
?readts
=
fso.OpenTextFile(modAddress,
1
)
?87
?readcontent
=
readts.ReadAll()
?88
?readts.close
?89
?
end?function
?90
?91
?
public
?
function
?replaceContent(strOne,strTwo)
'
替換內容
?92
?content
=
replace
(content,strOne,strTwo)
?93
?
end?function
?94
?95
?
public
?
sub
?asp2html(filename,filecontent)
'
生成shtml文件
?96
?
set
?writets
=
fso.CreateTextFile(filename,
true
)
?97
?writets.Write(filecontent)
?98
?writets.close
?99
?
end?sub
100
101
end
?class
102
103
class?GetConnection
104
'
??連接數據庫類
105
'
??調用方法:
106
'
??dim?myconn
107
'
??set?myconn=new?GetConnection
108
'
109
?
private
?conn,connStr
110
?
public
?rs
111
?
private
?
sub
?class_initialize()
'
類初始化
112
?connStr
=
"
Provider=SQLOLEDB.1;?Data?Source=(local);?Initial?Catalog=myDATABASE;?User?ID=sa;?Password=
"
113
?
'
在此修改數據庫連接
114
?
set
?conn
=
Server.CreateObject(
"
ADODB.Connection
"
)
115
?conn.open?connStr
116
?
end?sub
117
118
?
public
?
function
?openRS(sql)
119
?
set
?rs
=
conn.execute(sql)
120
?
if
?rs.eof?
and
?rs.bof?
then
121
?openRS
=
false
122
?
else
123
?openRS
=
true
124
?
end
?
if
125
?
end?function
126
127
?
public
?
sub
?errMassege(mm)?
128
?response.write(
"
<center><p><font?size=7?color=red>
"
&
mm
&
"
</font></p><center>
"
)?
129
?
end?sub
130
131
?
private
?
sub
?class_terminate()
'
銷毀類
132
?conn.close
133
?
set
?conn
=
nothing
134
?
end?sub
135
136
end
?class
137
138
posted on 2006-06-26 11:00
jackstudio 閱讀(508)
評論(0) 編輯 收藏 所屬分類:
asp