<!--#include file="conn.asp"-->
<title>轩溪下载系统1.3 To 3.2 升级程序</title>
<style type=text/css>
A:link,A:active,A:visited{TEXT-DECORATION:none ;Color:#000000}A:hover{TEXT-DECORATION: underline;Color:#4455aa}
BODY{FONT-SIZE: 12px;COLOR: #000000;FONT-FAMILY:  宋体;}
font{line-height : normal ;}
TD{font-family: 宋体;font-size: 12px;line-height : 15px ;}
th{background-color: #4E5187;color: white;font-size: 12px;font-weight:bold;}
td.TableBody1{background-color: #F8F8F8;line-height : normal ;}
.tableBorder1{width:760;border: 1px; background-color: #4E5187;}
</style>
<%
'On Error Resume Next
Server.ScriptTimeout=9999999
Dim Rs,SQL,i,SqlStr,tRs
Dim objADOXDatabase
Dim tConn,tConnStr
Set tConn = Server.CreateObject("ADODB.Connection")
tConnStr = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = " & Server.MapPath("Database.Mdb")
tConn.Open tConnStr

If isSqlDataBase = 0 Then
	SqlStr="Now()"
Else
	SqlStr="GetData()"
End If
Dim TableTop,TableEnd
TableTop="<TABLE border=""0"" width=""100%"" align=""center"" class=tableBorder1 cellspacing=0 cellpadding=0><tr><td class=tablebody1>"
TableEnd="</td></tr></table>"

Select Case Request("Action")
Case "Step1"
	Step1()
Case "Step2"
	Step2()
Case "Step3"
	Step3()
Case "Step4"
	Step4()
Case Else
	Step1()
End Select

tConn.Close
Set tConn=Nothing
Sub Step1()
%>
<table cellspacing=1 cellpadding=3 align=center class=tableBorder1>
<tr>
<th width="100%" height="24" colspan="2" ID=TableTitleLink>轩溪下载系统1.3 To 3.2 升级程序 
</th></tr>
<tr>
<td width="100%" Class="tablebody1" style="font-size: 12px;line-height : 18px ;">
<B>操作说明，请仔细阅读操作说明后进行操作</B>：<BR>
1、<font color=blue>强烈建议您在本地计算机系统完成升级操作并做好<font color=red>备份</font>工作，如不能在本地进行升级操作也请升级前<font color=red>备份</font>好您的所有文件和数据</font><BR>
2、系统要求：使用W2k(Pro&Server)+IIS5.0或者Win2003+IIS6，请不要在Win9x下进行操作<BR>
3、升级前请把要升级的数据库放到update目录中<BR>
  <B>注意：</B><BR>
<font color=red>本升级程序只用于1.3版本向3.2版本升级，不能用于1.0 - 1.2 向3.2版本的升级，如果要升级请先升级至1.3再升级</font><BR>
升级的时候可能会提示要手动修改部分数据表<BR>
</td>
</tr>
<FORM METHOD=POST ACTION="?Action=Step2">
<tr>
<td width="100%" Class="tablebody1" style="font-size: 12px;line-height : 18px ;">
<B>第一步</B>：
<input name="submit" type="submit" value="升级数据库第一步">
</td>
</tr>
</FORM>
</table>
<TABLE cellSpacing="0" cellPadding="0" width="98%" border="0" align="center">
<tr><td align="center"><table align="center"><tr>
<td align="center">Powered By ：<a href = "http://www.xuanxi.net" target = "_blank">轩溪</a><br>Copyright &copy;2003 - 2005  <a href="http://www.xuanxi.net"><font face=Verdana, Arial, Helvetica, sans-serif><b>Xuanxi<font color=#CC0000>.Net</font></b></font></a>
</td></tr></table>
<%
End Sub
'更新数据库结构
Sub Step2()
%>
<table cellspacing=1 cellpadding=3 align=center class=tableBorder1>
<tr>
<th width="100%" height="24" colspan="2" ID=TableTitleLink>轩溪下载系统1.3 To 3.2 升级程序 第一步执行完毕
</th></tr>
<FORM METHOD=POST ACTION="?Action=Step3">
<tr>
<td width="100%" Class="tablebody1" style="font-size: 12px;line-height : 18px ;">
<B>第二步</B>：
<input name="submit" type="submit" value="升级第二步">&nbsp;&nbsp;在下面未提示所有更新成功的情况下请不要点击下一步
</td>
</tr>
</FORM>
</table>
<%
'删除老数据表
DelTable "NC_Config"
DelTable "NC_Channel"
DelTable "NC_LockIP"
DelTable "NC_Log"
DelTable "NC_Skins"
'DelColumn "NC_SoftSite","Hits"
DelColumn "NC_Softinfo","LastHitTime"
ChangeTableFieldName "NC_Article", "datetime", "InfoTime"
RenameTable "NC_Essay","NC_SoftEssay"
'新建表NC_Config
Sql="CREATE TABLE NC_Config ("&_
	"id int IDENTITY (1, 1) NOT NULL ,"&_
	"System_set text NOT NULL ,"&_
	"stopReadme text NOT NULL ,"&_
	"Badwords text NOT NULL ,"&_
	"Badwordr text NOT NULL ,"&_
	"tempid int default 0 NOT NULL ,"&_
	"Register_Key nvarchar (50) NOT NULL ,"&_
	"Register_Code nvarchar (50) NOT NULL ,"&_
	"System_ver nvarchar (50) NOT NULL ,"&_
	"SetupDir nvarchar (50) NOT NULL ,"&_
	"Script_FSO nvarchar (100) NOT NULL ,"&_
	"LockipList text NOT NULL)"
Conn.Execute(Sql)
If Err Then
	Response.Write TableTop & "新建表NC_Config<font color=blue>失败</font>，原因：" & Err.Description & "<BR>" & TableEnd
	Err.Clear
	Response.Flush
Else
	Response.Write TableTop & "新建表NC_Config成功<BR>" & TableEnd
	Response.Flush
End If

'新建表NC_AdColumn
Sql="CREATE TABLE NC_AdColumn ("&_
	"ID int IDENTITY (1, 1) NOT NULL ,"&_
	"HomeName nvarchar (100) NOT NULL ,"&_
	"Remark text NOT NULL ,"&_
	"LinkUrl nvarchar (255) NOT NULL ,"&_
	"ImageUrl nvarchar (255) NOT NULL ,"&_
	"Height smallint Default 0 NOT NULL ,"&_
	"Width smallint Default 0 NOT NULL ,"&_
	"topmargin smallint Default 0 NOT NULL ,"&_
	"sidemargin smallint Default 0 NOT NULL ,"&_
	"topmargin1 smallint Default 0 NOT NULL ,"&_
	"sidemargin1 smallint Default 0 NOT NULL ,"&_
	"topmargin2 smallint Default 0 NOT NULL ,"&_
	"sidemargin2 smallint Default 0 NOT NULL ,"&_
	"AdsType smallint Default 0 NOT NULL ,"&_
	"ColumnID smallint Default 0 NOT NULL ,"&_
	"AdsHits int default 0 NOT NULL ,"&_
	"AdsTime datetime Default "&SqlStr&" NOT NULL ,"&_
	"LinkType smallint Default 0 NOT NULL ,"&_
	"isLock smallint Default 0 NOT NULL)"
Conn.Execute(Sql)
If Err Then
	Response.Write TableTop & "新建表NC_AdColumn<font color=blue>失败</font>，原因：" & Err.Description & "<BR>" & TableEnd
	Err.Clear
	Response.Flush
Else
	Response.Write TableTop & "新建表NC_AdColumn成功<BR>" & TableEnd
	Response.Flush
End If

'新建表NC_ArticleEssay
Sql="CREATE TABLE NC_ArticleEssay ("&_
	"id int IDENTITY (1, 1) NOT NULL ,"&_
	"ArticleID int default 0 NOT NULL ,"&_
	"userid int default 0 NOT NULL ,"&_
	"username nvarchar (50) NOT NULL ,"&_
	"content text NOT NULL ,"&_
	"usermail nvarchar (50) NOT NULL ,"&_
	"Grade smallint Default 0 NOT NULL ,"&_
	"postime datetime Default "&SqlStr&" NOT NULL ,"&_
	"postip nvarchar (50) NOT NULL)"
Conn.Execute(Sql)
If Err Then
	Response.Write TableTop & "新建表NC_ArticleEssay<font color=blue>失败</font>，原因：" & Err.Description & "<BR>" & TableEnd
	Err.Clear
	Response.Flush
Else
	Response.Write TableTop & "新建表NC_ArticleEssay成功<BR>" & TableEnd
	Response.Flush
End If

'新建表NC_Message
Sql="CREATE TABLE NC_Message ("&_
	"id int IDENTITY (1, 1) NOT NULL ,"&_
	"statid tinyint Default 0 NOT NULL ,"&_
	"title nvarchar (100) NOT NULL ,"&_
	"content text NOT NULL ,"&_
	"writer nvarchar (50) NOT NULL ,"&_
	"postime datetime Default "&SqlStr&" NOT NULL ,"&_
	"hits int default 0 NOT NULL ,"&_
	"isTop tinyint Default 0 NOT NULL ,"&_
	"isUpdate tinyint Default 1 NOT NULL)"
Conn.Execute(Sql)
If Err Then
	Response.Write TableTop & "新建表NC_Message<font color=blue>失败</font>，原因：" & Err.Description & "<BR>" & TableEnd
	Err.Clear
	Response.Flush
Else
	Response.Write TableTop & "新建表NC_Message成功<BR>" & TableEnd
	Response.Flush
End If

'新建表NC_Template
Sql="CREATE TABLE NC_Template ("&_
	"id int IDENTITY (1, 1) NOT NULL ,"&_
	"TempName nvarchar (50) NOT NULL ,"&_
	"TempDir nvarchar (50) NOT NULL ,"&_
	"Style_CSS text NOT NULL default '|||@@@|||@@@|||@@@|||',"&_
	"Main_Style text NOT NULL default '|||@@@|||@@@|||@@@|||',"&_
	"temp_index text NOT NULL default '|||@@@|||@@@|||@@@|||',"&_
	"temp_sorting text NOT NULL default '|||@@@|||@@@|||@@@|||',"&_
	"temp_softinfo text NOT NULL default '|||@@@|||@@@|||@@@|||',"&_
	"temp_search text NOT NULL default '|||@@@|||@@@|||@@@|||',"&_
	"temp_infoindex text NOT NULL default '|||@@@|||@@@|||@@@|||',"&_
	"temp_listing text NOT NULL default '|||@@@|||@@@|||@@@|||',"&_
	"temp_article text NOT NULL default '|||@@@|||@@@|||@@@|||',"&_
	"temp_help text NOT NULL default '|||@@@|||@@@|||@@@|||')"
Conn.Execute(Sql)
If Err Then
	Response.Write TableTop & "新建表NC_Template<font color=blue>失败</font>，原因：" & Err.Description & "<BR>" & TableEnd
	Err.Clear
	Response.Flush
Else
	Response.Write TableTop & "新建表NC_Template成功<BR>" & TableEnd
	Response.Flush
End If

'新建表NC_Vote
Sql="CREATE TABLE NC_Vote ("&_
	"id int IDENTITY (1, 1) NOT NULL ,"&_
	"Topic nvarchar (100) NOT NULL ,"&_
	"Choose_1 nvarchar (50) NOT NULL ,"&_
	"Choose_2 nvarchar (50) NOT NULL ,"&_
	"Choose_3 nvarchar (50) NOT NULL ,"&_
	"Choose_4 nvarchar (50) NOT NULL ,"&_
	"Choose_5 nvarchar (50) NOT NULL ,"&_
	"ChooseNum_1 int default 0 NOT NULL ,"&_
	"ChooseNum_2 int default 0 NOT NULL ,"&_
	"ChooseNum_3 int default 0 NOT NULL ,"&_
	"ChooseNum_4 int default 0 NOT NULL ,"&_
	"ChooseNum_5 int default 0 NOT NULL ,"&_
	"isLock smallint Default 0 NOT NULL ,"&_
	"bgcolor nvarchar (50) NOT NULL ,"&_
	"FontColor nvarchar (50) NOT NULL ,"&_
	"FontSize tinyint Default 0 NOT NULL ,"&_
	"VoteTime datetime Default "&SqlStr&" NOT NULL ,"&_
	"VoteNum int default 0 NOT NULL ,"&_
	"VoteType smallint Default 0 NOT NULL)"
Conn.Execute(Sql)
If Err Then
	Response.Write TableTop & "新建表NC_Vote<font color=blue>失败</font>，原因：" & Err.Description & "<BR>" & TableEnd
	Err.Clear
	Response.Flush
Else
	Response.Write TableTop & "新建表NC_Vote成功<BR>" & TableEnd
	Response.Flush
End If

'新建表NC_ServerSite
Sql="CREATE TABLE NC_ServerSite ("&_
	"serverid int default 0 NOT NULL ,"&_
	"ServerName nvarchar (50) NOT NULL ,"&_
	"ServerUrl nvarchar (255) NOT NULL ,"&_
	"depth smallint Default 0 NOT NULL ,"&_
	"rootid smallint Default 0 NOT NULL ,"&_
	"orders smallint Default 0 NOT NULL ,"&_
	"parentid smallint Default 0 NOT NULL ,"&_
	"strparent nvarchar (255) NOT NULL ,"&_
	"child smallint Default 0 NOT NULL ,"&_
	"isLock smallint Default 0 NOT NULL)"
Conn.Execute(Sql)
If Err Then
	Response.Write TableTop & "新建表NC_ServerSite<font color=blue>失败</font>，原因：" & Err.Description & "<BR>" & TableEnd
	Err.Clear
	Response.Flush
Else
	Response.Write TableTop & "新建表NC_ServerSite成功<BR>" & TableEnd
	Response.Flush
End If

AddColumn "NC_Article","ArticleType","nvarchar (50)"
AddColumn "NC_Article","isTop","smallint Default 0"
AddColumn "NC_Article","DayHits","int default 0"
AddColumn "NC_Article","WeekHits","int default 0"
AddColumn "NC_Article","MonthHits","int default 0"
AddColumn "NC_Article","HitsTime","datetime Default "&SqlStr&""

AddColumn "NC_SoftInfo","MoneyNum","money Default 0"
AddColumn "NC_SoftInfo","isTop","smallint Default 0"
AddColumn "NC_SoftInfo","HitsTime","datetime Default "&SqlStr&""

AddColumn "NC_SoftSite","serverid","int default 0"

AddColumn "NC_Class","readme","nvarchar (255)"
AddColumn "NC_Class","parentid","int default 0"
AddColumn "NC_Class","strParent","nvarchar (200)"
AddColumn "NC_Class","Child","int default 0"

AddColumn "NC_SoftSort","readme","nvarchar (255)"
AddColumn "NC_SoftSort","parentid","int default 0"
AddColumn "NC_SoftSort","strParent","nvarchar (200)"
AddColumn "NC_SoftSort","Child","int default 0"

Conn.Execute ("update NC_SoftSite set serverid=0")
Response.Write TableTop & "更新表NC_SoftSite成功<BR>" & TableEnd
Response.Flush
Conn.Execute ("update NC_SoftInfo set isTop=0,DayHits=0,WeekHits=0,MonthHits=0,HitsTime="&SqlStr&",MoneyNum=0")
Response.Write TableTop & "更新表NC_SoftInfo成功<BR>" & TableEnd
Response.Flush
Conn.Execute ("update NC_Article set isTop=0,DayHits=0,WeekHits=0,MonthHits=0,HitsTime="&SqlStr&"")
Response.Write TableTop & "更新表NC_Article成功<BR>" & TableEnd
Response.Flush
Conn.Execute ("update NC_SoftSort set orders=0,parentid=0,strParent='0',Child=0")
Response.Write TableTop & "更新表NC_SoftSort成功<BR>" & TableEnd
Response.Flush
Conn.Execute ("update NC_Class set orders=0,parentid=0,strParent='0',Child=0")
Response.Write TableTop & "更新表NC_Class成功<BR>" & TableEnd
Response.Flush
Response.Write TableTop & "<B>升级数据库结构成功，请进入下一步</B><Br>" & TableEnd
Response.Flush

	CloseData()
End Sub

Sub Step3()
%>
<table cellspacing=1 cellpadding=3 align=center class=tableBorder1>
<tr>
<th width="100%" height="24" colspan="2" ID=TableTitleLink>轩溪下载系统1.3 To 3.2 升级程序 第二步执行完毕
</th></tr>
<FORM METHOD=POST ACTION="?Action=Step4">
<tr>
<td width="100%" Class="tablebody1" style="font-size: 12px;line-height : 18px ;">
<B>第三步</B>：
<input name="submit" type="submit" value="压缩数据库">&nbsp;&nbsp;在下面未提示所有更新成功的情况下请不要点击下一步
</td>
</tr>
</FORM>
</table>
<%
	Set tRs=tConn.Execute("Select * From [NC_Config]")
	Do While Not tRs.Eof
		Conn.Execute("insert into [NC_Config] (System_set,stopReadme,Badwords,Badwordr,tempid,Register_Key,Register_Code,System_ver,SetupDir,Script_FSO,LockipList) Values ('"&tRs("System_set")&"','"&tRs("stopReadme")&"','"&tRs("Badwords")&"','"&tRs("Badwordr")&"',"&tRs("tempid")&",'"&tRs("Register_Key")&"','"&tRs("Register_Code")&"','"&tRs("System_ver")&"','"&tRs("SetupDir")&"','"&tRs("Script_FSO")&"','"&tRs("LockipList")&"')")
	tRs.MoveNext
	Loop
	Set tRs=Nothing
	Response.Write TableTop & "导入数据到NC_Config表成功<BR>" & TableEnd
	Response.Flush

	Set tRs=tConn.Execute("Select * From [NC_Template]")
	Do While Not tRs.Eof
		Conn.Execute("insert into [NC_Template] (TempName,TempDir,Style_CSS,Main_Style,temp_index,temp_sorting,temp_softinfo,temp_search,temp_infoindex,temp_listing,temp_article,temp_help) Values ('"&Replace(tRs("TempName"),"'","''")&"','"&Replace(tRs("TempDir"),"'","''")&"','"&Replace(tRs("Style_CSS"),"'","''")&"','"&Replace(tRs("Main_Style"),"'","''")&"','"&Replace(tRs("temp_index"),"'","''")&"','"&Replace(tRs("temp_sorting"),"'","''")&"','"&Replace(tRs("temp_softinfo"),"'","''")&"','"&Replace(tRs("temp_search"),"'","''")&"','"&Replace(tRs("temp_infoindex"),"'","''")&"','"&Replace(tRs("temp_listing"),"'","''")&"','"&Replace(tRs("temp_article"),"'","''")&"','"&Replace(tRs("temp_help"),"'","''")&"')")
	tRs.MoveNext
	Loop
	Set tRs=Nothing
	Response.Write TableTop & "导入数据到NC_Template表成功<BR>" & TableEnd
	Response.Flush

	Set Rs=Conn.Execute("Select * From [NC_Class] where depth=1")
	i=1
	Do While Not Rs.Eof
		Conn.Execute ("update [NC_Class] set orders=orders+"&i&",parentid="&Rs("rootid")&",strParent='"&Rs("rootid")&"',readme='"&Rs("ClassName")&"' where classid="&Rs("classid")&"")
	Rs.MoveNext
	i=i+1
	Loop
	Set Rs=Nothing
	Set Rs=Conn.Execute("Select * From [NC_Class] where depth=0")
	Do While Not Rs.Eof
		Set trs=Conn.execute("select count(*) from [NC_Class] where rootid="&rs("rootid"))
			Conn.Execute ("update [NC_Class] set Child=Clng("&trs(0)&"-1),readme='"&Rs("ClassName")&"' where classid="&Rs("classid")&"")
		Set tRs=Nothing
	Rs.MoveNext
	Loop
	Set Rs=Nothing
	Response.Write TableTop & "更新表NC_Class成功<BR>" & TableEnd
	Response.Flush

	Set Rs=Conn.Execute("Select * From [NC_SoftSort] where depth=1")
	i=1
	Do While Not Rs.Eof
		Conn.Execute ("update [NC_SoftSort] set orders=orders+"&i&",parentid="&Rs("rootid")&",strParent='"&Rs("rootid")&"',readme='"&Rs("SortName")&"' where sortid="&Rs("sortid")&"")
	Rs.MoveNext
	i=i+1
	Loop
	Set Rs=Nothing
	Set Rs=Conn.Execute("Select * From [NC_SoftSort] where depth=0")
	Do While Not Rs.Eof
		Set trs=Conn.execute("select count(*) from [NC_SoftSort] where rootid="&rs("rootid"))
			Conn.Execute ("update [NC_SoftSort] set Child=Clng("&trs(0)&"-1),readme='"&Rs("SortName")&"' where sortid="&Rs("sortid")&"")
		Set tRs=Nothing
	Rs.MoveNext
	Loop
	Set Rs=Nothing
	Response.Write TableTop & "更新表NC_SoftSort成功<BR>" & TableEnd
	Response.Flush

	Response.Write TableTop & "<B>轩溪下载系统1.3 To 3.2升级成功，您可以进行其它操作</B><Br>" & TableEnd
	Response.Flush

	CloseData()
End Sub

'压缩数据库
Sub Step4()
	'On Error Resume Next
%>
<table cellspacing=1 cellpadding=3 align=center class=tableBorder1>
<tr>
<th width="100%" height="24" colspan="2" ID=TableTitleLink>轩溪下载系统1.3 To 3.2 升级程序 所有操作执行完毕
</th></tr>
<tr>
<td width="100%" Class="tablebody1" style="font-size: 12px;line-height : 18px ;">
<B>轩溪下载系统升级成功</B>！<BR>
本地升级的请把升级好的数据库和新版文件传到网站相关目录<BR>
网络升级的请把新版文件传到网站相关目录<BR>
上传前，请修改Conn.asp文件中的数据库连接为下载系统数据库地址<BR>
上传前，请做好文件和数据库的备份<BR>
</td>
</tr>
</table>
<%
	CloseData()
	Response.Write TableTop & CompactDB(Server.Mappath(Request("db")),False) & TableEnd
End Sub
Sub CloseData()
	Set objADOXDatabase = Nothing
	Conn.Close
	Set Conn=Nothing
End Sub

'删除字段通用函数
Sub DelColumn(TableName,ColumnName)
	On Error Resume Next
	Conn.Execute("Alter Table "&TableName&" Drop "&ColumnName&"")
	If Err Then
		Response.Write TableTop & "删除 "&TableName&" 表中字段<font color=blue>错误</font>，请手动将数据库中 <B>"&ColumnName&"</B> 字段删除，原因" & Err.Description & "<BR>" & TableEnd
		Err.Clear
		Response.Flush
	Else
		Response.Write TableTop & "删除 "&TableName&" 表中字段 "&ColumnName&" 成功 <BR>" & TableEnd
		Response.Flush
	End If
End Sub

'添加字段通用函数
Sub AddColumn(TableName,ColumnName,ColumnType)
	On Error Resume Next
	Conn.Execute("Alter Table "&TableName&" Add "&ColumnName&" "&ColumnType&"")
	If Err Then
		Response.Write TableTop & "新建 "&TableName&" 表中字段<font color=blue>错误</font>，请手动将数据库中 <B>"&ColumnName&"</B> 字段建立，属性为 <B>"&ColumnType&"</B>，原因" & Err.Description & "<BR>" & TableEnd
		Err.Clear
		Response.Flush
	Else
		Response.Write TableTop & "新建 "&TableName&" 表中字段 "&ColumnName&" 成功 <BR>" & TableEnd
		Response.Flush
	End If
End Sub

'删除表通用函数
Sub DelTable(TableName)
	On Error Resume Next
	Conn.Execute("Drop Table "&TableName&"")
	If Err Then
		Response.Write TableTop & "删除 "&TableName&" 表<font color=blue>错误</font>，请手动将数据库中 <B>"&TableName&"</B> 表删除，原因" & Err.Description & "<BR>" & TableEnd
		Err.Clear
		Response.Flush
	Else
		Response.Write TableTop & "删除 "&TableName&" 表成功 <BR>" & TableEnd
		Response.Flush
	End If
End Sub

'更改数据库表名，入口参数：老表名、新表名
Sub RenameTable(oldName, newName)
	On Error Resume Next
	Set objADOXDatabase = Server.CreateObject("ADOX.Catalog")
	objADOXDatabase.ActiveConnection = ConnStr
	objADOXDatabase.Tables(oldName).Name = newName
	If Err Then
		Response.Write TableTop & "更改表名<font color=blue>错误</font>，请手动将数据库中 <B>"&oldName&"</B> 表名更改为 <B>"&newName&"</B>，原因" & Err.Description & "<BR>" & TableEnd
		Err.Clear
		Response.Flush
	Else
		Response.Write TableTop & "更改表名 "&OldName&" To "&newName&" 成功 <BR>" & TableEnd
		Response.Flush
	End If
End Sub

'更改数据库表中字段名，入口参数：表名、老字段名、新字段名
Sub ChangeTableFieldName(MyTableName, oldName, newName)
	On Error Resume Next
	Set objADOXDatabase = Server.CreateObject("ADOX.Catalog")
	objADOXDatabase.ActiveConnection = ConnStr
	Set MyTable = objADOXDatabase.Tables(MyTableName)
	MyTable.Columns(OldName).Name = newName
	If Err Then
		Response.Write TableTop & "更改字段名<font color=blue>错误</font>，请手动将数据库中 <B>"&MyTableName&"</B>表中 <B>"&oldName&"</B> 字段名更改为 <B>"&newName&"</B>，原因" & Err.Description & "<BR>" & TableEnd
		Err.Clear
		Response.Flush
	Else
		Response.Write TableTop & "更改数据库中 <B>"&MyTableName&"</B>表中字段名 "&OldName&" To "&newName&" 成功 <BR>" & TableEnd
		Response.Flush
	End If
End Sub 

'=====================压缩参数=========================
Function CompactDB(dbPath, boolIs97)
	On Error Resume Next
	Dim fso, Engine, strDBPath,JET_3X
	strDBPath = left(dbPath,instrrev(DBPath,"\"))
	Set fso = CreateObject("Scripting.FileSystemObject")
	If Err Then
		Err.Clear
		CompactDB = "您当前升级操作目录不支持FSO，请手动进行压缩数据库操作!" & vbCrLf
		Exit Function
	End If
	If fso.FileExists(dbPath) Then
		fso.CopyFile dbpath,strDBPath & "temp.mdb"
		Set Engine = CreateObject("JRO.JetEngine")

		If boolIs97 = "True" Then
			Engine.CompactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & "temp.mdb", _
			"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & "temp1.mdb;" _
			& "Jet OLEDB:Engine Type=" & JET_3X
		Else
			Engine.CompactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & "temp.mdb", _
			"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & "temp1.mdb"
		End If

		fso.CopyFile strDBPath & "temp1.mdb",dbpath
		fso.DeleteFile(strDBPath & "temp.mdb")
		fso.DeleteFile(strDBPath & "temp1.mdb")
		Set fso = Nothing
		Set Engine = Nothing
		CompactDB = "你的数据库, " & dbpath & ", 已经压缩成功!" & vbCrLf
	Else
		CompactDB = "数据库名称或路径不正确. 请重试!" & vbCrLf
	End If
End Function
%>