<!--#include file="Start.asp"-->
<%
Server.ScriptTimeOut = 9999999
Dim EndTime, i
Dim Conn_Old, db_type, db_access, db_sql
Dim UpdateTable, TableName, Info_CurrentUpdate, RefreshNum
Dim RecordNum, RecordIndex, TotalRecordNum, TotalRecordIndex
Dim ArrSkinID(), ArrTemplateID()
ReDim ArrSkinID(0, 0), ArrTemplateID(0, 0)

Dim ChannelDir
TotalRecordIndex = 0

Dim rsNew, rsOld
Set rsNew = Server.CreateObject("ADODB.Recordset")
Set rsOld = Server.CreateObject("ADODB.Recordset")

Response.Write "<html>" & vbCrLf
Response.Write "<head>" & vbCrLf
Response.Write "<title>动易 6.6版 数据转换/迁移程序</title>" & vbCrLf
Response.Write "<meta http-equiv=""Content-Type"" content=""text/html; charset=gb2312"">" & vbCrLf
Response.Write "<link href=""" & AdminDir & "/Admin_STYLE.CSS"" rel=""stylesheet"" type=""text/css"">" & vbCrLf
Response.Write "</head>" & vbCrLf
Response.Write "<body>" & vbCrLf

Action = Trim(request("Action"))
Select Case Action
Case "SelectDatabase"
    Call SelectDatabase
Case "SelectTable"
    Call SelectTable
Case "GetRefreshNum"
    Call GetRefreshNum
Case "Update"
    Call Update
Case "Del"
    Call Del
Case Else
    Call Main
End Select

Call CloseConn
Response.Write "</body></html>"


Sub Main()
    Response.Write "<table width=""700"" border=""0"" align=""center"" cellpadding=""1"" cellspacing=""1"" class=""border"">" & vbCrLf
    Response.Write "  <form name=""myform"" method=""post"" action=""DataTrans.asp"">" & vbCrLf
    Response.Write "  <tr align=""center"" class=""topbg"">" & vbCrLf
    Response.Write "    <td height=""25""><strong>动易 6.6版 数据转换/迁移程序</strong></td>" & vbCrLf
    Response.Write "  </tr>" & vbCrLf
    Response.Write "  <tr>" & vbCrLf
    Response.Write "    <td height=""60"" align=right>" & vbCrLf
    Response.Write "      <table width=""100%"" height=""60"" border=""0"" cellpadding=""0"" cellspacing=""0"" style=""border-bottom: 1px solid #999999;"">" & vbCrLf
    Response.Write "        <tr>" & vbCrLf
    Response.Write "          <td>" & vbCrLf
    Response.Write "            <strong>操作步骤：</strong><br>" & vbCrLf
    Response.Write "            &nbsp;&nbsp;          <font color='#FF0000'>本程序支持动易 6.6版的任一数据库版本之间的数据转换。可以在ACCESS--SQL、ACCESS--ACCESS、SQL--SQL之间互相转换。使用前请一定要认真仔细的阅读下面的操作步骤及注意事项！！！</font>" & vbCrLf
    Response.Write "          </td>" & vbCrLf
    'Response.Write "          <td align=""right"" width=""180""><img src='http://www.powereasy.net/images/logo.gif' border='0'  width=""180""></td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "      </table>"
    Response.Write "    </td>" & vbCrLf
    Response.Write "  </tr>" & vbCrLf
    Response.Write "  <tr class=""tdbg"">" & vbCrLf
    Response.Write "    <td>" & vbCrLf
    Response.Write "      <table width=""90%"" align=""center"" height=""350"" border=""0"" cellpadding=""0"" cellspacing=""0"">" & vbCrLf
    Response.Write "        <tr>" & vbCrLf
    Response.Write "          <td>" & vbCrLf
    Response.Write "            确定已了解下面的内容后，单击[下一步]继续。" & vbCrLf
    Response.Write "            <textarea rows=""21"" cols=""105"" style=""font-size: 9pt;"" readonly>"
	Response.Write "●约定：" & vbCrLf
	Response.Write " 当前你正在使用的网站的数据库称为“目标数据库”，要转数据过来的数据库称为“源数据库”。 " & vbCrLf
	Response.Write "" & vbCrLf
	Response.Write "●操作步骤：" & vbCrLf
	Response.Write " 1、备份您的源数据库。" & vbCrLf
	Response.Write " 2、如果目标数据库是SQL数据库，则请新建sql数据库，用系统提供的SiteWeaver6.6.sql建表，并设置好数据库连接文件（不要运行Install.asp文件）。" & vbCrLf
	Response.Write " 3、将本程序文件（DataTrans.asp）复制到WEB文件夹。" & vbCrLf
	Response.Write " 4、打开浏览器，在地址栏中输入本迁移程序的地址，运行本程序。如：http://localhost/DataTrans.asp。" & vbCrLf
	Response.Write " 5、认真阅读本说明后点“下一步”，开始迁移操作。" & vbCrLf
	Response.Write " 6、迁移成功后，请到系统后台认真仔细的检查相关数据。 " & vbCrLf
	Response.Write "" & vbCrLf
	Response.Write "●注意事项： " & vbCrLf
	Response.Write " 1、本迁移程序只适用于官方发布版本的数据库迁移，不适用于其他修改版或美化版的迁移工作。" & vbCrLf
	Response.Write " 2、本操作不建议您直接在服务器上进行，最好在本地架起调试环境然后进行迁移工作。" & vbCrLf
	Response.Write " 3、本操作的更新时间视您数据的多少以及服务器（或本地机器）的配置决定，如果数据很多，更新可能很慢。" & vbCrLf
	Response.Write " 4、迁移过程中千万不能刷新页面或关闭浏览器，如果出现超时或者错误提示，请使用备份数据重新进行迁移操作。" & vbCrLf
	Response.Write " 5、若您是直接在服务器进行迁移，则操作成功完成后，一定要删除此文件！以免带来安全隐患。" 
    Response.Write "</textarea>" & vbCrLf
    Response.Write "          </td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "      </table>"
    Response.Write "      <hr>" & vbCrLf
    Response.Write "      <table width=""100%"" height=""30"" border=""0"" cellpadding=""0"" cellspacing=""0"">" & vbCrLf
    Response.Write "        <tr>" & vbCrLf
    Response.Write "          <td align=""center"">" & vbCrLf
    Response.Write "            <input type=""hidden"" name=""Action"" value=""SelectDatabase"">" & vbCrLf
    Response.Write "            <input name=""Submit"" type=""submit"" value="" 下一步 "">" & vbCrLf
    Response.Write "          </td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "      </table>"
    Response.Write "    </td>" & vbCrLf
    Response.Write "  </tr>" & vbCrLf
    Response.Write "  </form>" & vbCrLf
    Response.Write "</table>" & vbCrLf
End Sub

Sub SelectDatabase()
    Response.Write "<table width=""700"" border=""0"" align=""center"" cellpadding=""1"" cellspacing=""1"" class=""border"">" & vbCrLf
    Response.Write "  <form name=""myform"" method=""post"" action=""DataTrans.asp"">" & vbCrLf
    Response.Write "  <tr align=""center"" class=""topbg"">" & vbCrLf
    Response.Write "    <td height=""25""><strong>动易 6.6版 数据转换/迁移程序</strong></td>" & vbCrLf
    Response.Write "  </tr>" & vbCrLf
    Response.Write "  <tr>" & vbCrLf
    Response.Write "    <td height=""60"" align=right>" & vbCrLf
    Response.Write "      <table width=""100%"" height=""60"" border=""0"" cellpadding=""0"" cellspacing=""0"" style=""border-bottom: 1px solid #999999;"">" & vbCrLf
    Response.Write "        <tr>" & vbCrLf
    Response.Write "          <td>" & vbCrLf
    Response.Write "            <strong>选择数据库：</strong><br>" & vbCrLf
    Response.Write "            &nbsp;&nbsp;请指定源数据库类型及名称或连接字符串。" & vbCrLf
    Response.Write "          </td>" & vbCrLf
    Response.Write "          <td align=""right"" width=""180"" background=""http://www.powereasy.net/images/logo.gif"">&nbsp;</td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "      </table>"
    Response.Write "    </td>" & vbCrLf
    Response.Write "  </tr>" & vbCrLf
    Response.Write "  <tr class=""tdbg"">" & vbCrLf
    Response.Write "    <td>" & vbCrLf
    Response.Write "      <table width=""90%"" align=""center"" height=""350"" border=""0"" cellpadding=""0"" cellspacing=""0"">" & vbCrLf
    Response.Write "        <tr>" & vbCrLf
    Response.Write "          <td valign=""top"">" & vbCrLf
    Response.Write "            <br>" & vbCrLf
    Response.Write "            如果源数据库为 <font color=""blue"">ACCESS</font> 数据库，请将数据库文件复制到当前网站目录中，并在下面的输入框中输入数据库文件名。<br>" & vbCrLf
    Response.Write "            如果源数据库为 <font color=""blue"">SQL</font> 数据库，请确保可以连接上数据库所在的服务器，并添写数据库连接字符串。<br>" & vbCrLf
    Response.Write "            添写完成后，单击[下一步]继续。<br>" & vbCrLf
    Response.Write "            <br>" & vbCrLf
    Response.Write "            <br>" & vbCrLf
    Response.Write "            <fieldset><legend>数据库连接</legend>" & vbCrLf
    Response.Write "            <table width=""650"" border=""0"" cellpadding=""10"" cellspacing=""5"">" & vbCrLf
    Response.Write "              <tr>" & vbCrLf
    Response.Write "                <td><input type=""radio"" name=""db_type"" value=""ACCESS"" checked> ACCESS版数据库文件名：</td>" & vbCrLf
    Response.Write "                <td>" & vbCrLf
    Response.Write "                  <input name=""db_access"" type=""text"" value=""SiteWeaver6.6.mdb"" size=""28"">" & vbCrLf
    Response.Write "                </td>" & vbCrLf
    Response.Write "              </tr>" & vbCrLf
    Response.Write "              <tr>" & vbCrLf
    Response.Write "                <td><input type=""radio"" name=""db_type"" value=""SQL""> SQL版数据库连接字符串：</td>" & vbCrLf
    Response.Write "                <td><textarea name=""db_sql"" cols=""55"" rows=""5"">Provider = Sqloledb; User ID = PowerEasy; Password = PowerEasy*9988; Initial Catalog = SiteWeaver65; Data Source = (local);</textarea></td>" & vbCrLf
    Response.Write "              </tr>" & vbCrLf
    Response.Write "            </table>" & vbCrLf
    Response.Write "            </fieldset>" & vbCrLf
    Response.Write "          </td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "      </table>"
    Response.Write "      <hr>" & vbCrLf
    Response.Write "      <table width=""100%"" height=""30"" border=""0"" cellpadding=""0"" cellspacing=""0"">" & vbCrLf
    Response.Write "        <tr>" & vbCrLf
    Response.Write "          <td align=""center"">" & vbCrLf
    Response.Write "            <input name=""Action"" type=""hidden"" value=""GetRefreshNum"">" & vbCrLf
    Response.Write "            <input name=""PrevStep"" type=""button"" value="" 上一步 "" onclick=""history.go(-1)"">" & vbCrLf
    Response.Write "            <input name=""Submit"" type=""submit"" value="" 下一步 "">" & vbCrLf
    Response.Write "          </td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "      </table>"
    Response.Write "    </td>" & vbCrLf
    Response.Write "  </tr>" & vbCrLf
    Response.Write "  </form>" & vbCrLf
    Response.Write "</table>" & vbCrLf
End Sub

Sub GetRefreshNum()
    If CheckDatabase() = False Then Exit Sub
    Response.Write "<table width=""700"" border=""0"" align=""center"" cellpadding=""1"" cellspacing=""1"" class=""border"">" & vbCrLf
    Response.Write "  <form name=""myform"" method=""post"" action=""DataTrans.asp"">" & vbCrLf
    Response.Write "  <tr align=""center"" class=""topbg"">" & vbCrLf
    Response.Write "    <td height=""25""><strong>动易 6.6版 数据转换/迁移程序</strong></td>" & vbCrLf
    Response.Write "  </tr>" & vbCrLf
    Response.Write "  <tr>" & vbCrLf
    Response.Write "    <td height=""60"" align=right>" & vbCrLf
    Response.Write "      <table width=""100%"" height=""60"" border=""0"" cellpadding=""0"" cellspacing=""0"" style=""border-bottom: 1px solid #999999;"">" & vbCrLf
    Response.Write "        <tr>" & vbCrLf
    Response.Write "          <td>" & vbCrLf
    Response.Write "            <strong>填写刷新参数：</strong><br>" & vbCrLf
    Response.Write "            &nbsp;&nbsp;请指定升级进度条刷新参数。" & vbCrLf
    Response.Write "          </td>" & vbCrLf
    Response.Write "          <td align=""right"" width=""180"" background=""http://www.powereasy.net/images/logo.gif"">&nbsp;</td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "      </table>"
    Response.Write "    </td>" & vbCrLf
    Response.Write "  </tr>" & vbCrLf
    Response.Write "  <tr class=""tdbg"">" & vbCrLf
    Response.Write "    <td>" & vbCrLf
    Response.Write "      <table width=""90%"" align=""center"" height=""350"" border=""0"" cellpadding=""0"" cellspacing=""0"">" & vbCrLf
    Response.Write "        <tr>" & vbCrLf
    Response.Write "          <td valign=""top"">" & vbCrLf
    Response.Write "            <br>" & vbCrLf
    Response.Write "            此参数控制升级进度条显示快慢，请填写数值，<font color='red'>值越大显示越快</font>。<br>" & vbCrLf
    Response.Write "            如果源数据库内容多，很大（50M以上），可以修改此参数为较大值，如：100。<br>" & vbCrLf
	Response.Write "            添写完成后，单击[下一步]继续。<br>" & vbCrLf
    Response.Write "            <br>" & vbCrLf
    Response.Write "            <br>" & vbCrLf
    Response.Write "            <fieldset><legend>升级进度条</legend>" & vbCrLf
    Response.Write "            <table width=""650"" border=""0"" cellpadding=""10"" cellspacing=""5"">" & vbCrLf
    Response.Write "              <tr>" & vbCrLf
    Response.Write "                <td>升级进度条刷新参数：</td>" & vbCrLf
    Response.Write "                <td>" & vbCrLf
    Response.Write "                  <input name=""RefreshNum"" type=""text"" value=""10"" size=""20"">" & vbCrLf
    Response.Write "                </td>" & vbCrLf
    Response.Write "              </tr>" & vbCrLf
    Response.Write "            </table>" & vbCrLf
    Response.Write "            </fieldset>" & vbCrLf
    Response.Write "          </td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "      </table>"
    Response.Write "      <hr>" & vbCrLf
    Response.Write "      <table width=""100%"" height=""30"" border=""0"" cellpadding=""0"" cellspacing=""0"">" & vbCrLf
    Response.Write "        <tr>" & vbCrLf
    Response.Write "          <td align=""center"">" & vbCrLf
	Response.Write "            <input name=""db_access"" type=""hidden"" value=""" & db_access & """>" & vbCrLf
    Response.Write "            <input name=""db_sql"" type=""hidden"" value=""" & db_sql & """>" & vbCrLf
    Response.Write "            <input name=""db_type"" type=""hidden"" value=""" & db_type & """>" & vbCrLf
    Response.Write "            <input name=""Action"" type=""hidden"" value=""SelectTable"">" & vbCrLf
    Response.Write "            <input name=""PrevStep"" type=""button"" value="" 上一步 "" onclick=""history.go(-1)"">" & vbCrLf
    Response.Write "            <input name=""Submit"" type=""submit"" value="" 下一步 "">" & vbCrLf
    Response.Write "          </td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "      </table>"
    Response.Write "    </td>" & vbCrLf
    Response.Write "  </tr>" & vbCrLf
    Response.Write "  </form>" & vbCrLf
    Response.Write "</table>" & vbCrLf
End Sub

Function CheckDatabase()
    On Error Resume Next
    db_type = Trim(request("db_type"))
    CheckDatabase = False
    If db_type = "ACCESS" Then
        db_access = Trim(request("db_access"))
        If db_access = "" Then
            Response.Write "<br><br>请输入源数据库（Access版数据库）的文件名！"
            Exit Function
        End If
        Set Conn_Old = Server.CreateObject("ADODB.Connection")
        Conn_Old.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.mappath("" & db_access & "")
        Conn_Old.CommandTimeOut = 9999
        If Err.Number <> 0 Then
            Response.Write "<br><br>数据库连接错误，请确认输入的源数据库 （Access版数据库）的文件名是否正确，且已经复制（或上传）到动易 6.6版所在目录。"
            Exit Function
        End If
    ElseIf db_type = "SQL" Then
        db_sql = Trim(request("db_sql"))
        If db_sql = "" Then
            Response.Write "<br><br>请输入源数据库（SQL版数据库）的连接字符串！"
            Exit Function
        End If
        Set Conn_Old = Server.CreateObject("ADODB.Connection")
        Conn_Old.open db_sql
        Conn_Old.CommandTimeOut = 9999
        If Err.Number <> 0 Then
            Response.Write "<br><br>数据库连接错误，请确认输入的源数据库 （SQL版数据库）的连接字符串是否正确，特别是数据库服务器的IP地址。"
            Exit Function
        End If
    End If
    CheckDatabase = True
End Function

Sub SelectTable()
    If CheckDatabase() = False Then Exit Sub
    Response.Write "<table width=""700"" border=""0"" align=""center"" cellpadding=""1"" cellspacing=""1"" class=""border"">" & vbCrLf
    Response.Write "  <form name=""myform"" method=""post"" action=""DataTrans.asp"">" & vbCrLf
    Response.Write "  <tr align=""center"" class=""topbg"">" & vbCrLf
    Response.Write "    <td height=""25""><strong>动易 6.6版 数据转换/迁移程序</strong></td>" & vbCrLf
    Response.Write "  </tr>" & vbCrLf
    Response.Write "  <tr>" & vbCrLf
    Response.Write "    <td height=""60"" align=right>" & vbCrLf
    Response.Write "      <table width=""100%"" height=""60"" border=""0"" cellpadding=""0"" cellspacing=""0"" style=""border-bottom: 1px solid #999999;"">" & vbCrLf
    Response.Write "        <tr>" & vbCrLf
    Response.Write "          <td>" & vbCrLf
    Response.Write "            <strong>选择数据项：</strong><br>" & vbCrLf
    Response.Write "            &nbsp;&nbsp;请选择要转换/迁移的数据库内容。" & vbCrLf
    Response.Write "          </td>" & vbCrLf
    Response.Write "          <td align=""right"" width=""180"" background=""http://www.powereasy.net/images/logo.gif"">&nbsp;</td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "      </table>"
    Response.Write "    </td>" & vbCrLf
    Response.Write "  </tr>" & vbCrLf
    Response.Write "  <tr class=""tdbg"">" & vbCrLf
    Response.Write "    <td>" & vbCrLf
    Response.Write "      <table width=""90%"" align=""center"" height=""350"" border=""0"" cellpadding=""0"" cellspacing=""0"">" & vbCrLf
    Response.Write "        <tr>" & vbCrLf
    Response.Write "          <td valign=""top"">" & vbCrLf

    Response.Write "            <br>" & vbCrLf
    Response.Write "            <br>" & vbCrLf
    Response.Write "            <fieldset><legend>选择迁移内容</legend>" & vbCrLf
    Response.Write "            <table width=""650"" border=""0"" cellpadding=""0"" cellspacing=""8"">" & vbCrLf
    Response.Write "              <tr>" & vbCrLf
    Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_Config"" checked>网站配置</td>" & vbCrLf
    Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_Skin"" checked>网站风格</td>" & vbCrLf
    Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_Template"" checked>网站模板</td>" & vbCrLf
    Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_Channel"" checked>网站频道</td>" & vbCrLf
    Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_Class"" checked>网站栏目</td>" & vbCrLf
    Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_Special"" checked>所有专题</td>" & vbCrLf
    Response.Write "              </tr>" & vbCrLf
    Response.Write "              <tr>" & vbCrLf
    Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_Article"" checked>所有文章</td>" & vbCrLf
    Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_Soft"" checked>所有软件</td>" & vbCrLf
    Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_Photo"" checked>所有图片</td>" & vbCrLf
    Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_Product"" checked>所有商品</td>" & vbCrLf
    Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_GuestKind"" checked>留言类别</td>" & vbCrLf
    Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_GuestBook"" checked>网站留言</td>" & vbCrLf
    Response.Write "              </tr>" & vbCrLf
    Response.Write "              <tr>" & vbCrLf
    Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_Admin"" checked>网站管理员</td>" & vbCrLf
    Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_UserGroup"" checked>用户组</td>" & vbCrLf
    Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_User"" checked>会员记录</td>" & vbCrLf
    Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_Label"" checked>自定义标签</td>" & vbCrLf
    Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_Comment"" checked>评论</td>" & vbCrLf
    Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_JsFile"" checked>ＪＳ数据</td>" & vbCrLf
    Response.Write "              </tr>" & vbCrLf
    Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_Announce"" checked>网站公告</td>" & vbCrLf
    Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_AdZone"" checked>广告版位</td>" & vbCrLf
    Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_Advertisement"" checked>网站广告</td>" & vbCrLf
    Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_FsKind"" checked>友情链接类别</td>" & vbCrLf
    Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_FriendSite"" checked>友情链接</td>" & vbCrLf
    Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_Vote"" checked>网站调查</td>" & vbCrLf
    Response.Write "              </tr>" & vbCrLf
    Response.Write "              <tr>" & vbCrLf
    Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_Author"" checked>作者</td>" & vbCrLf
    Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_CopyFrom"" checked>来源</td>" & vbCrLf
    Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_NewKeys"" checked>关键字</td>" & vbCrLf
    Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_Producer"" checked>生产商</td>" & vbCrLf
    Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_Trademark"" checked>商标</td>" & vbCrLf
    Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_KeyLink"" checked>字符替换</td>" & vbCrLf
    Response.Write "              </tr>" & vbCrLf
    Response.Write "              <tr>" & vbCrLf
    Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_Log"" checked>网站日志</td>" & vbCrLf
    Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_Favorite"" checked>用户收藏</td>" & vbCrLf
    Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_Message"" checked>短消息</td>" & vbCrLf
    Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_Classroom"" checked>室场记录</td>" & vbCrLf
    Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_Equipment"" checked>设备记录</td>" & vbCrLf
    Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_UsedDetail"" checked>设备使用记录</td>" & vbCrLf
    Response.Write "              </tr>" & vbCrLf
    Response.Write "              <tr>" & vbCrLf
    Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_Bank"" checked>银行帐户</td>" & vbCrLf
    Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_BankrollItem"" checked>资金明细</td>" & vbCrLf
    Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_Card"" checked>充值卡</td>" & vbCrLf
    Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_ConsumeLog"" checked>消费明细</td>" & vbCrLf
    Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_OrderForm"" checked>订单</td>" & vbCrLf
    Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_OrderFormItem"" checked>订单明细</td>" & vbCrLf
    Response.Write "              </tr>" & vbCrLf
    Response.Write "              <tr>" & vbCrLf
    Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_DeliverType"" checked>送货方式</td>" & vbCrLf
    Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_DeliverItem"" checked>发退货记录</td>" & vbCrLf
    Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_Payment"" checked>在线支付记录</td>" & vbCrLf
    Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_PaymentType"" checked>付款方式</td>" & vbCrLf
    Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_PresentProject"" checked>促销方案</td>" & vbCrLf
    Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_TransferItem"" checked>订单过户记录</td>" & vbCrLf
    Response.Write "              </tr>" & vbCrLf
    Response.Write "              <tr>" & vbCrLf
    Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_Item"" checked>采集项目</td>" & vbCrLf
    Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_Filters"" checked>采集过滤</td>" & vbCrLf
    Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_HistrolyNews"" checked>采集历史记录</td>" & vbCrLf
	'star
	Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_AreaCollection"" checked>区域采集表</td>" & vbCrLf
	Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_City"" checked>邮政编码</td>" & vbCrLf
	Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_Client"" checked>顾客表</td>" & vbCrLf
    Response.Write "              </tr>" & vbCrLf
    Response.Write "              <tr>" & vbCrLf
	Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_Company"" checked>公司表</td>" & vbCrLf
	Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_ComplainItem"" checked>投诉项目</td>" & vbCrLf
	Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_Contacter"" checked>联系人表</td>" & vbCrLf
	Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_Country"" checked>国家表</td>" & vbCrLf
	Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_DeliverCharge"" checked>运费标准</td>" & vbCrLf
	Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_Dictionary"" checked>字典表</td>" & vbCrLf
    Response.Write "              </tr>" & vbCrLf
    Response.Write "              <tr>" & vbCrLf
	Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_DownError"" checked>下载报错</td>" & vbCrLf
	Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_DownServer"" checked>镜像服务器</td>" & vbCrLf
	Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_Friend"" checked>好友表</td>" & vbCrLf
	Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_HouseArea"" checked>房产区域表</td>" & vbCrLf
	Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_HouseConfig"" checked>房产栏目配置</td>" & vbCrLf
	Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_HouseCS"" checked>出售信息表</td>" & vbCrLf
    Response.Write "              </tr>" & vbCrLf
	Response.Write "              <tr>" & vbCrLf
	Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_HouseCZ"" checked>出租信息表</td>" & vbCrLf
	Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_HouseHZ"" checked>合租信息表</td>" & vbCrLf
	Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_HouseQG"" checked>求购信息表</td>" & vbCrLf
	Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_HouseQZ"" checked>求租信息表</td>" & vbCrLf
	Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_InfoS"" checked>专题关联表</td>" & vbCrLf
	Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_InvoiceItem"" checked>发票项目</td>" & vbCrLf
    Response.Write "              </tr>" & vbCrLf
	Response.Write "              <tr>" & vbCrLf
	Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_JobCategory"" checked>工作类别</td>" & vbCrLf
	Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_Page"" checked>自定义页面</td>" & vbCrLf
	Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_PageClass"" checked>自定义页分类</td>" & vbCrLf
	Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_Position"" checked>地区表</td>" & vbCrLf
	Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_PositionSupplyInfo"" checked>申请职位表</td>" & vbCrLf
	Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_Province"" checked>省市表</td>" & vbCrLf
    Response.Write "              </tr>" & vbCrLf
	Response.Write "              <tr>" & vbCrLf
	Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_RechargeLog"" checked>有效期明细</td>" & vbCrLf
	Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_Resume"" checked>简历</td>" & vbCrLf
	Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_ServiceItem"" checked>服务记录</td>" & vbCrLf
	Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_Space"" checked>聚合空间</td>" & vbCrLf
	Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_SpaceBook"" checked>聚合空间图书</td>" & vbCrLf
	Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_SpaceComment"" checked>聚合空间评论</td>" & vbCrLf
    Response.Write "              </tr>" & vbCrLf
	Response.Write "              <tr>" & vbCrLf
	Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_SpaceDiary"" checked>聚合空间日志</td>" & vbCrLf
	Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_SpaceKind"" checked>聚合空间分类</td>" & vbCrLf
	Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_SpaceLink"" checked>聚合空间链接</td>" & vbCrLf
	Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_SpaceMusic"" checked>聚合空间音乐</td>" & vbCrLf
	Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_SpacePhoto"" checked>聚合空间图片</td>" & vbCrLf
	Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_SpaceVisitor"" checked>聚合空间来访</td>" & vbCrLf
    Response.Write "              </tr>" & vbCrLf
	Response.Write "              <tr>" & vbCrLf
	Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_SubCompany"" checked>分公司</td>" & vbCrLf
	Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_Supply"" checked>供求</td>" & vbCrLf
	Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_Supply_Company"" checked>供求公司</td>" & vbCrLf
	Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_TemplateProject"" checked>模板方案</td>" & vbCrLf
	Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_WorkPlace"" checked>工作地点</td>" & vbCrLf
	Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_ShoppingCarts"" checked>购物车表</td>" & vbCrLf
	Response.Write "              </tr>" & vbCrLf
	Response.Write "              <tr>" & vbCrLf
	Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_PayPlatform"" checked>在线支付平台</td>" & vbCrLf
	Response.Write "                <td width=""16%""><input name=""UpdateTable"" type=""checkbox"" id=""UpdateTable"" value=""PE_MailChannel"" checked>邮件订阅列表</td>" & vbCrLf
	Response.Write "              </tr>" & vbCrLf
	Response.Write "            </table>" & vbCrLf
    Response.Write "            </fieldset>" & vbCrLf

    Response.Write "          </td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "      </table>"
    Response.Write "      <hr>" & vbCrLf
    Response.Write "      <table width=""100%"" height=""30"" border=""0"" cellpadding=""0"" cellspacing=""0"">" & vbCrLf
    Response.Write "        <tr>" & vbCrLf
    Response.Write "          <td align=""center"">" & vbCrLf
    Response.Write "            <input name=""db_access"" type=""hidden"" value=""" & db_access & """>" & vbCrLf
    Response.Write "            <input name=""db_sql"" type=""hidden"" value=""" & db_sql & """>" & vbCrLf
    Response.Write "            <input name=""db_type"" type=""hidden"" value=""" & db_type & """>" & vbCrLf
    Response.Write "            <input name=""RefreshNum"" type=""hidden"" value=""" & Trim(request("RefreshNum")) & """>" & vbCrLf
	Response.Write "            <input name=""Action"" type=""hidden"" value=""Update"">" & vbCrLf
    Response.Write "            <input name=""PrevStep"" type=""button"" value="" 上一步 "" onclick=""history.go(-1)"">" & vbCrLf
    Response.Write "            <input name=""StartUpdate"" type=""submit"" value=""开始迁移"">" & vbCrLf
    Response.Write "          </td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "      </table>"
    Response.Write "    </td>" & vbCrLf
    Response.Write "  </tr>" & vbCrLf
    Response.Write "  </form>" & vbCrLf
    Response.Write "</table>" & vbCrLf
End Sub

Sub Update()
    BeginTime = Timer
    If CheckDatabase() = False Then Exit Sub
	RefreshNum=PE_Clng(Trim(request("RefreshNum")))
	If RefreshNum<10 then RefreshNum=10
    UpdateTable = Trim(request("UpdateTable"))
    TotalRecordNum = 0
    If InStr(UpdateTable, ",") > 0 Then
        Dim arrUpdateTable, intTemp
        arrUpdateTable = Split(UpdateTable, ",")
        For intTemp = 0 To UBound(arrUpdateTable)
            TotalRecordNum = TotalRecordNum + GetRecordNum(Trim(arrUpdateTable(intTemp)))
        Next
    Else
        TotalRecordNum = GetRecordNum(Trim(UpdateTable))
    End If

    Response.Write "<table id=""Update_Table"" style=""display:"" width=""700"" border=""0"" align=""center"" cellpadding=""1"" cellspacing=""1"" class=""border"">" & vbCrLf
    Response.Write "  <form name=""myform"" method=""post"" action=""DataTrans.asp"">" & vbCrLf
    Response.Write "  <tr align=""center"" class=""topbg"">" & vbCrLf
    Response.Write "    <td height=""25""><strong>动易 6.6版 数据转换/迁移程序</strong></td>" & vbCrLf
    Response.Write "  </tr>" & vbCrLf
    Response.Write "  <tr>" & vbCrLf
    Response.Write "    <td height=""60"" align=right>" & vbCrLf
    Response.Write "      <table width=""100%"" height=""60"" border=""0"" cellpadding=""0"" cellspacing=""0"" style=""border-bottom: 1px solid #999999;"">" & vbCrLf
    Response.Write "        <tr>" & vbCrLf
    Response.Write "          <td>" & vbCrLf
    Response.Write "            <strong>正在迁移：</strong><br>" & vbCrLf
    Response.Write "            &nbsp;&nbsp;迁移过程中请勿刷新页面或关闭窗口！</font><br>" & vbCrLf
    Response.Write "          </td>" & vbCrLf
    Response.Write "          <td align=""right"" width=""180"" background=""http://www.powereasy.net/images/logo.gif"">&nbsp;</td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "      </table>"
    Response.Write "    </td>" & vbCrLf
    Response.Write "  </tr>" & vbCrLf
    Response.Write "  <tr class=""tdbg"">" & vbCrLf
    Response.Write "    <td>" & vbCrLf
    Response.Write "      <table width=""90%"" align=""center"" height=""350"" border=""0"" cellpadding=""0"" cellspacing=""0"">" & vbCrLf
    Response.Write "        <tr>" & vbCrLf
    Response.Write "          <td valign=""top"">" & vbCrLf
    Response.Write "            <fieldset><legend>迁移进度</legend>" & vbCrLf
    Response.Write "              <table border=""0"" cellspacing=""1"" cellpadding=""1"">" & vbCrLf
    Response.Write "                <tr>" & vbCrLf
    Response.Write "                  <td>" & vbCrLf
    Response.Write "                    <table width=""634"">" & vbCrLf
    Response.Write "                      <tr>" & vbCrLf
    Response.Write "                        <td width=""240"">当前进度：<span id=""Info_CurrentPercent"" name=""Info_CurrentPercent"">0</span>%</td>" & vbCrLf
    Response.Write "                        <td><span id=""Info_CurrentUpdate"">123</span></td>" & vbCrLf
    Response.Write "                        <td align=""right""><span id=""Info_CurrentRecord"" name=""Info_CurrentRecord""></span></td>" & vbCrLf
    Response.Write "                      </tr>" & vbCrLf
    Response.Write "                    </table>" & vbCrLf
    Response.Write "                    <table width=""634"" height=""20"" border=""0"" cellspacing=""1"" cellpadding=""1"" bgcolor=""#000000"" align=""center"">" & vbCrLf
    Response.Write "                      <tr>" & vbCrLf
    Response.Write "                        <td bgcolor=""#ffffff"">" & vbCrLf
    Response.Write "                          <table name=""PercentBar"" id=""PercentBar"" width=""0"" height=""18"" bgcolor=""green"" border=""0"" cellspacing=""0"" cellpadding=""0""><tr><td></td></tr></table>" & vbCrLf
    Response.Write "                        </td>" & vbCrLf
    Response.Write "                      </tr>" & vbCrLf
    Response.Write "                    </table>" & vbCrLf
    Response.Write "                    <br>" & vbCrLf
    Response.Write "                    <table width=""634"">" & vbCrLf
    Response.Write "                      <tr>" & vbCrLf
    Response.Write "                        <td>总体进度：<span id=""Info_TotalPercent"" name=""Info_TotalPercent"">0</span>%</td>" & vbCrLf
    Response.Write "                        <td align=""right""><span id=""Info_TotalRecord"" name=""Info_TotalRecord""></span></td>" & vbCrLf
    Response.Write "                      </tr>" & vbCrLf
    Response.Write "                    </table>" & vbCrLf
    Response.Write "                    <table width=""634"" height=""20"" border=""0"" cellspacing=""1"" cellpadding=""1"" bgcolor=""#000000"" align=""center"">" & vbCrLf
    Response.Write "                      <tr>" & vbCrLf
    Response.Write "                        <td bgcolor=""#ffffff"">" & vbCrLf
    Response.Write "                          <table name=""TotalPercentBar"" id=""TotalPercentBar"" width=""0"" height=""18"" bgcolor=""blue"" border=""0"" cellspacing=""0"" cellpadding=""0""><tr><td></td></tr></table>" & vbCrLf
    Response.Write "                        </td>" & vbCrLf
    Response.Write "                      </tr>" & vbCrLf
    Response.Write "                    </table>" & vbCrLf
    Response.Write "                    <br>" & vbCrLf
    Response.Write "                  </td>" & vbCrLf
    Response.Write "                </tr>" & vbCrLf
    Response.Write "              </table>" & vbCrLf
    Response.Write "            </fieldset>" & vbCrLf
    Response.Write "            <br>" & vbCrLf
    Response.Write "            <textarea id='UpdateInfo' rows=""11"" cols=""105"" style=""font-size: 9pt;"" readonly></textarea>" & vbCrLf

    Response.Write "          </td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "      </table>"
    Response.Write "      <hr>" & vbCrLf
    Response.Write "      <table width=""100%"" height=""30"" border=""0"" cellpadding=""0"" cellspacing=""0"">" & vbCrLf
    Response.Write "        <tr>" & vbCrLf
    Response.Write "          <td align=""center"">" & vbCrLf
    Response.Write "          </td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "      </table>"
    Response.Write "    </td>" & vbCrLf
    Response.Write "  </tr>" & vbCrLf
    Response.Write "  </form>" & vbCrLf
    Response.Write "</table>" & vbCrLf

    Response.Write "<table id=""Success_Table"" style=""display:none"" width=""700"" border=""0"" align=""center"" cellpadding=""1"" cellspacing=""1"" class=""border"">" & vbCrLf
    Response.Write "  <form name=""myform"" method=""post"" action=""DataTrans.asp"">" & vbCrLf
    Response.Write "  <tr align=""center"" class=""topbg"">" & vbCrLf
    Response.Write "    <td height=""25""><strong>动易 6.6版 数据转换/迁移程序</strong></td>" & vbCrLf
    Response.Write "  </tr>" & vbCrLf
    Response.Write "  <tr>" & vbCrLf
    Response.Write "    <td height=""60"" align=right>" & vbCrLf
    Response.Write "      <table width=""100%"" height=""60"" border=""0"" cellpadding=""0"" cellspacing=""0"" style=""border-bottom: 1px solid #999999;"">" & vbCrLf
    Response.Write "        <tr>" & vbCrLf
    Response.Write "          <td>" & vbCrLf
    Response.Write "            <strong>迁移完成：</strong><br>" & vbCrLf
    Response.Write "            &nbsp;&nbsp;成功将源数据库迁移至目标数据库！</font><br>" & vbCrLf
    Response.Write "          </td>" & vbCrLf
    Response.Write "          <td align=""right"" width=""180"" background=""http://www.powereasy.net/images/logo.gif"">&nbsp;</td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "      </table>"
    Response.Write "    </td>" & vbCrLf
    Response.Write "  </tr>" & vbCrLf
    Response.Write "  <tr class=""tdbg"">" & vbCrLf
    Response.Write "    <td>" & vbCrLf
    Response.Write "      <table width=""90%"" align=""center"" height=""350"" border=""0"" cellpadding=""0"" cellspacing=""0"">" & vbCrLf
    Response.Write "        <tr>" & vbCrLf
    Response.Write "          <td valign=""top"">" & vbCrLf
    Response.Write "            <br>" & vbCrLf
    Response.Write "            恭喜您，从源数据库迁移至目标数据库成功！！！<br>" & vbCrLf
    Response.Write "            共耗时：<span id=""Info_Timer""></span>秒。<br>" & vbCrLf
    Response.Write "            <font color=red>若您是直接在服务器进行迁移，则请立即删除此文件！以免带来安全隐患。</font><br><br>" & vbCrLf
    Response.Write "            升级成功后，请到后台管理<font color='#FF0000'>认真仔细的</font>检查相关数据。<br>"
    Response.Write "          </td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "      </table>"
    Response.Write "      <hr>" & vbCrLf
    Response.Write "      <table width=""100%"" height=""30"" border=""0"" cellpadding=""0"" cellspacing=""0"">" & vbCrLf
    Response.Write "        <tr>" & vbCrLf
    Response.Write "          <td align=""center"">" & vbCrLf
    Response.Write "            <input type=""hidden"" name=""Action"" value=""SelectDatabase"">" & vbCrLf
    Response.Write "            <input name=""delfile"" type=""button"" value="" 删除此程序 "" onclick=""location='DataTrans.asp?Action=Del'"">" & vbCrLf
    Response.Write "            <input name=""close"" type=""button"" value="" 关闭此窗口 "" onclick=""javascript:onclick=window.close()"">" & vbCrLf
    Response.Write "          </td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "      </table>"
    Response.Write "    </td>" & vbCrLf
    Response.Write "  </tr>" & vbCrLf
    Response.Write "  </form>" & vbCrLf
    Response.Write "</table>" & vbCrLf


    Call Update_Purview
    Call Update_PE_Field

    If FoundInArr(UpdateTable, "PE_Config") = True Then Call Update_Table("PE_Config", "", "", "网站配置")
    If FoundInArr(UpdateTable, "PE_Skin") = True Then Call Update_PE_Skin
    If FoundInArr(UpdateTable, "PE_Template") = True Then Call Update_PE_Template
    If FoundInArr(UpdateTable, "PE_Class") = True Then Call Update_Table("PE_Class", "ClassID", "SkinID,TemplateID", "网站栏目")
    If FoundInArr(UpdateTable, "PE_Special") = True Then Call Update_Table("PE_Special", "SpecialID", "SkinID,TemplateID", "所有专题")

    If FoundInArr(UpdateTable, "PE_Article") = True Then Call Update_Table("PE_Article", "ArticleID", "SkinID,TemplateID", "所有文章")
    If FoundInArr(UpdateTable, "PE_Soft") = True Then Call Update_Table("PE_Soft", "SoftID", "SkinID,TemplateID", "所有软件")
    If FoundInArr(UpdateTable, "PE_Photo") = True Then Call Update_Table("PE_Photo", "PhotoID", "SkinID,TemplateID", "所有图片")
    If FoundInArr(UpdateTable, "PE_Product") = True Then Call Update_Table("PE_Product", "ProductID", "SkinID,TemplateID", "所有商品")
    If FoundInArr(UpdateTable, "PE_GuestKind") = True Then Call Update_Table("PE_GuestKind", "KindID", "", "留言类别")
    If FoundInArr(UpdateTable, "PE_GuestBook") = True Then Call Update_Table("PE_GuestBook", "GuestID", "", "留言")

    If FoundInArr(UpdateTable, "PE_Admin") = True Then Call Update_Table("PE_Admin", "ID", "ID", "网站管理员")
    If FoundInArr(UpdateTable, "PE_UserGroup") = True Then Call Update_Table("PE_UserGroup", "GroupID", "", "用户组")
    If FoundInArr(UpdateTable, "PE_Label") = True Then Call Update_Table("PE_Label", "LabelID", "LabelID", "自定义标签")
    If FoundInArr(UpdateTable, "PE_Comment") = True Then Call Update_Table("PE_Comment", "CommentID", "CommentID", "评论")
    If FoundInArr(UpdateTable, "PE_JsFile") = True Then Call Update_Table("PE_JsFile", "ID", "ID", "JS代码")

    If FoundInArr(UpdateTable, "PE_Announce") = True Then Call Update_Table("PE_Announce", "ID", "ID", "网站公告")
    If FoundInArr(UpdateTable, "PE_AdZone") = True Then Call Update_Table("PE_AdZone", "ZoneID", "", "广告版位")
    If FoundInArr(UpdateTable, "PE_Advertisement") = True Then Call Update_Table("PE_Advertisement", "ADID", "", "网站广告")
    If FoundInArr(UpdateTable, "PE_FsKind") = True Then Call Update_Table("PE_FsKind", "KindID", "", "友情链接类别")
    If FoundInArr(UpdateTable, "PE_FriendSite") = True Then Call Update_Table("PE_FriendSite", "ID", "ID", "友情链接")
    If FoundInArr(UpdateTable, "PE_Vote") = True Then Call Update_Table("PE_Vote", "ID", "ID", "网站调查")

    If FoundInArr(UpdateTable, "PE_Author") = True Then Call Update_Table("PE_Author", "ID", "ID", "作者")
    If FoundInArr(UpdateTable, "PE_CopyFrom") = True Then Call Update_Table("PE_CopyFrom", "ID", "ID", "来源")
    If FoundInArr(UpdateTable, "PE_NewKeys") = True Then Call Update_Table("PE_NewKeys", "ID", "ID", "关键字")
    If FoundInArr(UpdateTable, "PE_Producer") = True Then Call Update_Table("PE_Producer", "ProducerID", "ProducerID", "生产商")
    If FoundInArr(UpdateTable, "PE_Trademark") = True Then Call Update_Table("PE_Trademark", "TrademarkID", "TrademarkID", "商标")
    If FoundInArr(UpdateTable, "PE_KeyLink") = True Then Call Update_Table("PE_KeyLink", "ID", "ID", "字符替换")

    If FoundInArr(UpdateTable, "PE_Log") = True Then Call Update_Table("PE_Log", "LogID", "LogID", "网站日志")
    If FoundInArr(UpdateTable, "PE_Favorite") = True Then Call Update_Table("PE_Favorite", "ID", "ID", "用户收藏")
    If FoundInArr(UpdateTable, "PE_Message") = True Then Call Update_Table("PE_Message", "ID", "ID", "短消息")
    If FoundInArr(UpdateTable, "PE_Classroom") = True Then Call Update_Table("PE_Classroom", "ID", "ID", "室场记录")
    If FoundInArr(UpdateTable, "PE_Equipment") = True Then Call Update_Table("PE_Equipment", "ID", "ID", "设备记录")
    If FoundInArr(UpdateTable, "PE_UsedDetail") = True Then Call Update_Table("PE_UsedDetail", "ID", "ID", "设备使用记录")

    If FoundInArr(UpdateTable, "PE_Bank") = True Then Call Update_Table("PE_Bank", "BankID", "", "银行帐户")
    If FoundInArr(UpdateTable, "PE_BankrollItem") = True Then Call Update_Table("PE_BankrollItem", "ItemID", "ItemID", "资金明细")
    If FoundInArr(UpdateTable, "PE_Card") = True Then Call Update_Table("PE_Card", "CardID", "CardID", "充值卡")
    If FoundInArr(UpdateTable, "PE_ConsumeLog") = True Then Call Update_Table("PE_ConsumeLog", "LogID", "LogID", "消费明细")
    If FoundInArr(UpdateTable, "PE_OrderForm") = True Then Call Update_Table("PE_OrderForm", "OrderFormID", "", "订单")
    If FoundInArr(UpdateTable, "PE_OrderFormItem") = True Then Call Update_Table("PE_OrderFormItem", "ItemID", "", "订单明细")
	If FoundInArr(UpdateTable, "PE_RechargeLog") = True Then Call Update_Table("PE_RechargeLog", "LogID", "LogID", "有效期明细")
    If FoundInArr(UpdateTable, "PE_InvoiceItem") = True Then Call Update_Table("PE_InvoiceItem", "InvoiceID", "InvoiceID", "发票项目")
    If FoundInArr(UpdateTable, "PE_ShoppingCarts") = True Then Call Update_Table("PE_ShoppingCarts", "CartItemID", "CartItemID", "购物车表")

    If FoundInArr(UpdateTable, "PE_DeliverType") = True Then Call Update_Table("PE_DeliverType", "TypeID", "", "送货方式")
    If FoundInArr(UpdateTable, "PE_DeliverItem") = True Then Call Update_Table("PE_DeliverItem", "DeliverID", "DeliverID", "发退货记录")
    If FoundInArr(UpdateTable, "PE_PaymentType") = True Then Call Update_Table("PE_PaymentType", "TypeID", "", "付款方式")
    If FoundInArr(UpdateTable, "PE_Payment") = True Then Call Update_Table("PE_Payment", "PaymentID", "", "在线支付记录")
    If FoundInArr(UpdateTable, "PE_PresentProject") = True Then Call Update_Table("PE_PresentProject", "ProjectID", "ProjectID", "促销方案")
    If FoundInArr(UpdateTable, "PE_TransferItem") = True Then Call Update_Table("PE_TransferItem", "ItemID", "ItemID", "订单过户记录")
    If FoundInArr(UpdateTable, "PE_PayPlatform") = True Then Call Update_Table("PE_PayPlatform", "", "", "在线支付平台")

    If FoundInArr(UpdateTable, "PE_AreaCollection") = True Then Call Update_Table("PE_AreaCollection", "AreaID", "AreaID", "区域采集表")
	If FoundInArr(UpdateTable, "PE_Item") = True Then Call Update_Table("PE_Item", "ItemID", "ItemID", "采集项目")
    If FoundInArr(UpdateTable, "PE_Filters") = True Then Call Update_Table("PE_Filters", "FilterID", "FilterID", "采集过滤")
    If FoundInArr(UpdateTable, "PE_HistrolyNews") = True Then Call Update_Table("PE_HistrolyNews", "HistrolyNewsID", "HistrolyNewsID", "采集历史记录")

    If FoundInArr(UpdateTable, "PE_Channel") = True Then Call Update_Table("PE_Channel", "ChannelID", "", "网站频道")
    If FoundInArr(UpdateTable, "PE_User") = True Then Call Update_Table("PE_User", "", "", "会员数据")

    If FoundInArr(UpdateTable, "PE_Client") = True Then Call Update_Table("PE_Client", "", "", "顾客表")
    If FoundInArr(UpdateTable, "PE_Company") = True Then Call Update_Table("PE_Company", "", "", "公司表")
    If FoundInArr(UpdateTable, "PE_ComplainItem") = True Then Call Update_Table("PE_ComplainItem", "ItemID", "ItemID", "投诉项目")
    If FoundInArr(UpdateTable, "PE_ServiceItem") = True Then Call Update_Table("PE_ServiceItem", "ItemID", "ItemID", "服务记录")
	If FoundInArr(UpdateTable, "PE_Contacter") = True Then Call Update_Table("PE_Contacter", "", "", "联系人表")

    If FoundInArr(UpdateTable, "PE_DeliverCharge") = True Then Call Update_Table("PE_DeliverCharge", "ID", "ID", "运费标准")
    If FoundInArr(UpdateTable, "PE_Dictionary") = True Then Call Update_Table("PE_Dictionary", "FieldID", "FieldID", "字典表")
    If FoundInArr(UpdateTable, "PE_DownError") = True Then Call Update_Table("PE_DownError", "", "", "下载报错")
    If FoundInArr(UpdateTable, "PE_DownServer") = True Then Call Update_Table("PE_DownServer", "ServerID", "ServerID", "镜像服务器")
    If FoundInArr(UpdateTable, "PE_Friend") = True Then Call Update_Table("PE_Friend", "ID", "ID", "好友表")
'房产
    If FoundInArr(UpdateTable, "PE_HouseArea") = True Then Call Update_Table("PE_HouseArea", "", "", "房产区域表")
    If FoundInArr(UpdateTable, "PE_HouseConfig") = True Then Call Update_Table("PE_HouseConfig", "", "SkinID,TemplateID", "房产栏目配置")
    If FoundInArr(UpdateTable, "PE_HouseCS") = True Then Call Update_Table("PE_HouseCS", "HouseID", "", "出售信息表")
    If FoundInArr(UpdateTable, "PE_HouseCZ") = True Then Call Update_Table("PE_HouseCZ", "HouseID", "", "出租信息表")
    If FoundInArr(UpdateTable, "PE_HouseHZ") = True Then Call Update_Table("PE_HouseHZ", "HouseID", "", "合租信息表")
    If FoundInArr(UpdateTable, "PE_HouseQG") = True Then Call Update_Table("PE_HouseQG", "HouseID", "", "求购信息表")
    If FoundInArr(UpdateTable, "PE_HouseQZ") = True Then Call Update_Table("PE_HouseQZ", "HouseID", "", "求租信息表")

    If FoundInArr(UpdateTable, "PE_InfoS") = True Then Call Update_Table("PE_InfoS", "InfoID", "InfoID", "专题关联表")
    If FoundInArr(UpdateTable, "PE_TemplateProject") = True Then Call Update_Table("PE_TemplateProject", "TemplateProjectID", "", "模板方案")
'自定义页面
    If FoundInArr(UpdateTable, "PE_Page") = True Then Call Update_Table("PE_Page", "ID", "ID", "自定义页面")
    If FoundInArr(UpdateTable, "PE_PageClass") = True Then Call Update_Table("PE_PageClass", "ID", "ID", "自定义页分类")

    If FoundInArr(UpdateTable, "PE_Country") = True Then Call Update_Table("PE_Country", "CountryID", "CountryID", "国家表")
    If FoundInArr(UpdateTable, "PE_Province") = True Then Call Update_Table("PE_Province", "ProvinceID", "ProvinceID", "省市表")
    If FoundInArr(UpdateTable, "PE_City") = True Then Call Update_Table("PE_City", "AreaID", "AreaID", "邮政编码") 
	
'聚合空间
    If FoundInArr(UpdateTable, "PE_Space") = True Then Call Update_Table("PE_Space", "ID", "", "聚合空间")
    If FoundInArr(UpdateTable, "PE_SpaceBook") = True Then Call Update_Table("PE_SpaceBook", "ID", "", "聚合空间图书")
    If FoundInArr(UpdateTable, "PE_SpaceComment") = True Then Call Update_Table("PE_SpaceComment", "ID", "ID", "聚合空间评论")
    If FoundInArr(UpdateTable, "PE_SpaceDiary") = True Then Call Update_Table("PE_SpaceDiary", "ID", "", "聚合空间日志")
    If FoundInArr(UpdateTable, "PE_SpaceKind") = True Then Call Update_Table("PE_SpaceKind", "KindID", "", "聚合空间分类")
    If FoundInArr(UpdateTable, "PE_SpaceLink") = True Then Call Update_Table("PE_SpaceLink", "ID", "", "聚合空间链接")
    If FoundInArr(UpdateTable, "PE_SpaceMusic") = True Then Call Update_Table("PE_SpaceMusic", "ID", "", "聚合空间音乐")
    If FoundInArr(UpdateTable, "PE_SpacePhoto") = True Then Call Update_Table("PE_SpacePhoto", "ID", "", "聚合空间图片")
    If FoundInArr(UpdateTable, "PE_SpaceVisitor") = True Then Call Update_Table("PE_SpaceVisitor", "ID", "ID", "聚合空间来访")
'招聘
    If FoundInArr(UpdateTable, "PE_PositionSupplyInfo") = True Then Call Update_Table("PE_PositionSupplyInfo", "PositionSupplyInfoID", "", "申请职位表")
    If FoundInArr(UpdateTable, "PE_JobCategory") = True Then Call Update_Table("PE_JobCategory", "JobCategoryID", "", "工作类别")
    If FoundInArr(UpdateTable, "PE_Position") = True Then Call Update_Table("PE_Position", "PositionID", "", "职位表")
    If FoundInArr(UpdateTable, "PE_Resume") = True Then Call Update_Table("PE_Resume", "ResumeID", "", "简历")
    If FoundInArr(UpdateTable, "PE_SubCompany") = True Then Call Update_Table("PE_SubCompany", "SubCompanyID", "", "分公司")
    If FoundInArr(UpdateTable, "PE_WorkPlace") = True Then Call Update_Table("PE_WorkPlace", "WorkPlaceID", "", "工作地点")

    If FoundInArr(UpdateTable, "PE_Supply") = True Then Call Update_Table("PE_Supply", "SupplyID", "SkinID,TemplateID", "供求表")
    If FoundInArr(UpdateTable, "PE_Supply_Company") = True Then Call Update_Table("PE_Supply_Company", "", "", "供求公司")
    If FoundInArr(UpdateTable, "PE_MailChannel") = True Then Call Update_Table("PE_MailChannel", "", "", "邮件订阅列表")

    Call DelAllCache
    Conn_Old.Close
    Set Conn_Old = Nothing


    Response.Write "<script>" & vbCrLf
    Response.Write "Info_CurrentUpdate.innerHTML=""<font color='blue'>数据库迁移成功！</font>"";" & vbCrLf
    Response.Write "Info_Timer.innerHTML=""" & FormatNumber((Timer - BeginTime), 3) & """;" & vbCrLf
    Response.Write "Update_Table.style.display='none';" & vbCrLf
    Response.Write "Success_Table.style.display='';" & vbCrLf
    Response.Write "</script>" & vbCrLf


End Sub

Sub Del()
    On Error Resume Next
    Dim fso
    Set fso = CreateObject(objName_FSO)
    If fso.FileExists(Server.mappath("DataTrans.asp")) Then
        fso.DeleteFile Server.mappath("DataTrans.asp")
    End If
    If Err.Number <> 0 Then
        ErrMsg = ErrMsg & "<br><li>删除迁移程序（DataTrans.asp）失败，错误原因：" & Err.Description & "<br>请手动删除此文件。"
        Err.Clear
        Exit Sub
    Else
        Response.Write "<li>删除迁移程序（DataTrans.asp）成功！</li>"
    End If
End Sub

Sub Update_Purview()  '对目标数据库进行预处理
    On Error Resume Next
    Dim rsChannel
    Set rsChannel = Conn_Old.Execute("select ChannelDir from PE_Channel where ChannelType=1 Order by ChannelID Asc")
    Do While Not rsChannel.EOF
        If SystemDatabaseType = "SQL" Then
            Conn.Execute ("alter table PE_Admin add AdminPurview_" & rsChannel("ChannelDir") & " Int null")
        Else
            Conn.Execute ("alter table PE_Admin add COLUMN AdminPurview_" & rsChannel("ChannelDir") & " INTEGER")
        End If
        rsChannel.movenext
    Loop
    rsChannel.Close
    Set rsChannel = Nothing
End Sub

Sub Update_PE_Field()
    On Error Resume Next
    Dim SheetName, FieldName, sqlField
    rsOld.open "select F.FieldID,F.ChannelID,F.FieldName,F.Title,F.LabelName,F.Tips,F.FieldType,F.DefaultValue,F.Options,F.EnableNull,F.ShowOnForm,F.FieldLevel,C.ModuleType from PE_Field F inner join PE_Channel C on ABS(F.ChannelID)=C.ChannelID Order by F.ChannelID asc,F.FieldID Asc", Conn_Old, 1, 1
    Conn.Execute("delete from PE_Field")
	rsNew.open "select * from PE_Field", Conn, 1, 3
    Do While Not rsOld.EOF
        Select Case rsOld("ModuleType")
        Case 1
            SheetName = "PE_Article"
        Case 2
            SheetName = "PE_Soft"
        Case 3
            SheetName = "PE_Photo"
        Case 5
            SheetName = "PE_Product"
        End Select
            
        FieldName = rsOld("FieldName")
        If SystemDatabaseType = "SQL" Then
            If rsOld("FieldType") = 2 Then
                sqlField = "alter table " & SheetName & " add " & FieldName & " ntext null"
            Else
                sqlField = "alter table " & SheetName & " add " & FieldName & " nvarchar(255) null"
            End If
        Else
            If rsOld("FieldType") = 2 Then
                sqlField = "alter table " & SheetName & " add " & FieldName & " text null"
            Else
                sqlField = "alter table " & SheetName & " add " & FieldName & " varchar(255) null"
            End If
        End If
        Conn.Execute (sqlField)
        If Err Then
            Err.Clear
            Response.Write "<br><li>向 " & SheetName & " 表中添加自定义字段 " & FieldName & " 失败！</li>"
        Else
            rsNew.addnew
            rsNew("ChannelID") = rsOld("ChannelID") & ""
            rsNew("FieldName") = rsOld("FieldName")
            rsNew("Title") = rsOld("Title")
            rsNew("LabelName") = rsOld("LabelName")
            rsNew("Tips") = rsOld("Tips")
            rsNew("FieldType") = rsOld("FieldType")
            rsNew("DefaultValue") = rsOld("DefaultValue")
            rsNew("Options") = rsOld("Options")
            rsNew("EnableNull") = rsOld("EnableNull")
            rsNew("ShowOnForm") = rsOld("ShowOnForm")
            rsNew("FieldLevel") = rsOld("FieldLevel")
            rsNew.Update
        End If

        rsOld.movenext
    Loop
    rsOld.Close
    rsNew.Close
End Sub


Sub Update_PE_Skin()
    Dim maxrs
    TableName = "PE_Skin"
    Info_CurrentUpdate = "正在迁移网站风格"
    RecordNum = GetRecordNum(TableName)
    RecordIndex = 0
    Call RefreshPercentBar(True)
    rsOld.open "select * from PE_Skin Order by SkinID Asc", Conn_Old, 1, 1
    If Not (rsOld.EOF And rsOld.bof) Then
        ReDim ArrSkinID(rsOld.recordcount - 1, 1)
        i = 0
    End If
	Conn.Execute("delete from PE_Skin")
    rsNew.open "select * from PE_Skin", Conn, 1, 3
    Do While Not rsOld.EOF
        If i = 0 Then
            Conn.Execute ("update PE_Skin set IsDefault=" & PE_False & "")
        End If
        rsNew.addnew
        rsNew("SkinName") = rsOld("SkinName")
        rsNew("IsDefault") = False
        If rsOld("IsDefault") = True Then
            rsNew("IsDefaultInProject") = True
        Else
            rsNew("IsDefaultInProject") = False
        End If
        rsNew("Skin_CSS") = rsOld("Skin_CSS")
        rsNew("ProjectName") = rsOld("ProjectName")
        rsNew.Update

        Set maxrs = Conn.Execute("select max(SkinID) from PE_Skin")
        If Not IsNull(maxrs(0)) Then
            ArrSkinID(i, 0) = rsOld("SkinID")
            ArrSkinID(i, 1) = maxrs(0)
        End If
        Set maxrs = Nothing
        i = i + 1

        rsOld.movenext
        RecordIndex = RecordIndex + 1
        If (RecordIndex Mod RefreshNum) = 0 Then
            Call RefreshPercentBar(True)
        End If
        TotalRecordIndex = TotalRecordIndex + 1
        If Response.IsClientConnected = False Then Exit Do
    Loop
    rsOld.Close
    rsNew.Close
    Call RefreshPercentBar(False)
End Sub

Sub Update_PE_Template()
    Dim maxrs
    TableName = "PE_Template"
    Info_CurrentUpdate = "正在迁移网站模板"
    RecordNum = GetRecordNum(TableName)
    RecordIndex = 0
    Call RefreshPercentBar(True)
    rsOld.open "select * from PE_Template Order by ChannelID Asc,TemplateID Asc", Conn_Old, 1, 1
    If Not (rsOld.EOF And rsOld.bof) Then
        ReDim ArrTemplateID(rsOld.recordcount - 1, 1)
        i = 0
    End If
	Conn.execute("delete from PE_Template")
    rsNew.open "select * from PE_Template", Conn, 1, 3
    Do While Not rsOld.EOF
        rsNew.addnew
        rsNew("ChannelID") = rsOld("ChannelID")
        rsNew("TemplateName") = rsOld("TemplateName")
        rsNew("TemplateType") = rsOld("TemplateType")
        rsNew("TemplateContent") = rsOld("TemplateContent")
        rsNew("IsDefault") = PE_CBool(rsOld("IsDefault"))
        rsNew("ProjectName") = rsOld("ProjectName")
        If rsOld("IsDefault") = True Then
            rsNew("IsDefaultInProject") = True
        Else
            rsNew("IsDefaultInProject") = False
        End If
        rsNew("Deleted") = False
        rsNew.Update

        Set maxrs = Conn.Execute("select max(TemplateID) from PE_Template")
        If Not IsNull(maxrs(0)) Then
            ArrTemplateID(i, 0) = rsOld("TemplateID")
            ArrTemplateID(i, 1) = maxrs(0)
        End If
        Set maxrs = Nothing
        i = i + 1

        rsOld.movenext
        RecordIndex = RecordIndex + 1
        If (RecordIndex Mod RefreshNum) = 0 Then
            Call RefreshPercentBar(True)
        End If
        TotalRecordIndex = TotalRecordIndex + 1
    Loop
    rsOld.Close
    rsNew.Close

    Call RefreshPercentBar(False)
End Sub

Sub Update_Table(TableName, strOrder, ExcludeField, strUpdate)
    On Error Resume Next
    Info_CurrentUpdate = "正在迁移" & strUpdate
    RecordNum = GetRecordNum(TableName)
    RecordIndex = 0
    Call RefreshPercentBar(True)
    If FoundInArr("PE_Config,PE_Skin,PE_Template", TableName) = False Then
        Conn.Execute ("delete from " & TableName)
    End If
    If Trim(strOrder) = "" Then
        rsOld.open "select * from " & TableName, Conn_Old, 1, 1
    Else
        rsOld.open "select * from " & TableName & " Order by " & strOrder & " asc", Conn_Old, 1, 1
    End If

    rsNew.open "select * from " & TableName, Conn, 1, 3
    Do While Not rsOld.EOF
        If FoundInArr("PE_Config,PE_Skin,PE_Template", TableName) = False Then
            rsNew.addnew
        End If
        For i = 0 To rsOld.Fields.Count - 1
            If FoundInArr(ExcludeField, rsOld.Fields(i).Name) = False Then
                'On Error Resume Next
                Select Case rsOld.Fields(i).Type
                Case 3, 4, 5, 6, 17 '数值
                    If IsNumeric(rsOld(rsOld.Fields(i).Name).Value) Then
                        rsNew(rsOld.Fields(i).Name) = rsOld(rsOld.Fields(i).Name)
                    Else
                        rsNew(rsOld.Fields(i).Name) = 0
                    End If
                Case 11 '布尔
                    If IsNull(rsOld(rsOld.Fields(i).Name).Value) Then
                        rsNew(rsOld.Fields(i).Name) = False
                    Else
                        rsNew(rsOld.Fields(i).Name) = CBool(rsOld(rsOld.Fields(i).Name))
                    End If
                Case 7, 135 '日期
                    If IsDate(rsOld(rsOld.Fields(i).Name).Value) Then
                        rsNew(rsOld.Fields(i).Name) = rsOld(rsOld.Fields(i).Name)
                    Else
                        rsNew(rsOld.Fields(i).Name) = Now()
                    End If
                Case 202, 203 '文本、备注
                    rsNew(rsOld.Fields(i).Name) = rsOld(rsOld.Fields(i).Name) & ""
                Case Else
                    rsNew(rsOld.Fields(i).Name) = rsOld(rsOld.Fields(i).Name)
                End Select


                If Err.Number <> 0 Then
                    Response.Write "<br><br>出 错 表：" & TableName
                    Response.Write "<br>出错字段：" & rsOld.Fields(i).Name
                    Response.Write "<br>出错记录：" & RecordIndex
                    Response.Write "<br>出错内容：" & rsOld(rsOld.Fields(i).Name)
                    Response.Write "<br>错 误 号：" & Err.Number
                    Response.Write "<br>错误描述：" & Err.Description
                    Response.Write "<br>错误来源：" & Err.Source & "<br>"
                    Err.Clear
                    Response.End
                End If
            End If
        Next

        Select Case TableName

        Case "PE_Class"
            rsNew("SkinID") = GetNewID(ArrSkinID, rsOld("SkinID"))
            rsNew("TemplateID") = GetNewID(ArrTemplateID, rsOld("TemplateID"))
        Case "PE_GuestBook"
            If IsDate(rsOld("LastReplyTime")) Then rsNew("LastReplyTime") = rsOld("LastReplyTime")
            If IsDate(rsOld("GuestReplyDatetime")) Then rsNew("GuestReplyDatetime") = rsOld("GuestReplyDatetime")
        Case "PE_Product"
            rsNew("SkinID") = GetNewID(ArrSkinID, rsOld("SkinID"))
            rsNew("TemplateID") = GetNewID(ArrTemplateID, rsOld("TemplateID"))
        Case "PE_Special"
            rsNew("SkinID") = GetNewID(ArrSkinID, rsOld("SkinID"))
            rsNew("TemplateID") = GetNewID(ArrTemplateID, rsOld("TemplateID"))
        Case "PE_Channel"            
            rsNew("DefaultSkinID") = GetNewID(ArrSkinID, rsOld("DefaultSkinID"))
            rsNew("Template_Index") = GetNewID(ArrTemplateID, rsOld("Template_Index"))
        Case "PE_Article"
            rsNew("SkinID") = GetNewID(ArrSkinID, rsOld("SkinID"))
            rsNew("TemplateID") = GetNewID(ArrTemplateID, rsOld("TemplateID"))
        Case "PE_Photo"
            rsNew("SkinID") = GetNewID(ArrSkinID, rsOld("SkinID"))
            rsNew("TemplateID") = GetNewID(ArrTemplateID, rsOld("TemplateID"))
        Case "PE_Soft"
            rsNew("SkinID") = GetNewID(ArrSkinID, rsOld("SkinID"))
            rsNew("TemplateID") = GetNewID(ArrTemplateID, rsOld("TemplateID"))
		Case "PE_Supply"
            rsNew("SkinID") = GetNewID(ArrSkinID, rsOld("SkinID"))
            rsNew("TemplateID") = GetNewID(ArrTemplateID, rsOld("TemplateID"))
		Case "PE_HouseConfig"
            rsNew("SkinID") = GetNewID(ArrSkinID, rsOld("SkinID"))
            rsNew("TemplateID") = GetNewID(ArrTemplateID, rsOld("TemplateID"))
        End Select

        rsNew.Update
        rsOld.movenext
        RecordIndex = RecordIndex + 1
        If (RecordIndex Mod RefreshNum) = 0 Then
            Call RefreshPercentBar(True)
        End If
        TotalRecordIndex = TotalRecordIndex + 1
        If Response.IsClientConnected = False Then Exit Do
    Loop
    rsOld.Close
    rsNew.Close
    Call RefreshPercentBar(False)
End Sub


Sub RefreshPercentBar(IsFirstRecord)
    Response.Write "<script>" & vbCrLf
    If RecordIndex = 0 And IsFirstRecord = True Then
        Response.Write "Info_CurrentUpdate.innerHTML=""" & Info_CurrentUpdate & "..."";" & vbCrLf
        Response.Write "myform.UpdateInfo.value+=""" & Info_CurrentUpdate & "................."";" & vbCrLf
        Response.Write "myform.UpdateInfo.scrollTop=myform.UpdateInfo.scrollHeight;" & vbCrLf
    End If
    If RecordNum > 0 Then
        Response.Write "PercentBar.width="
        If Fix((RecordIndex / RecordNum) * 630) = 0 Then
            Response.Write "1;" & vbCrLf
        Else
            Response.Write Fix((RecordIndex / RecordNum) * 630) & ";" & vbCrLf
        End If
        Response.Write "Info_CurrentPercent.innerHTML=""" & FormatNumber(RecordIndex / RecordNum * 100, 2, -1) & """;" & vbCrLf
        Response.Write "Info_CurrentRecord.innerHTML=""" & RecordIndex & "/" & RecordNum & """;" & vbCrLf
        
    End If
    If RecordIndex >= RecordNum And IsFirstRecord = False Then
        Response.Write "myform.UpdateInfo.value+='成功！\n';" & vbCrLf
    End If
    If TotalRecordNum > 0 Then
        Response.Write "TotalPercentBar.width="
        If Fix((TotalRecordIndex / TotalRecordNum) * 630) = 0 Then
            Response.Write "1;" & vbCrLf
        Else
            Response.Write Fix((TotalRecordIndex / TotalRecordNum) * 630) & ";" & vbCrLf
        End If
        Response.Write "Info_TotalPercent.innerHTML=""" & FormatNumber(TotalRecordIndex / TotalRecordNum * 100, 2, -1) & """;" & vbCrLf
        Response.Write "Info_TotalRecord.innerHTML=""" & TotalRecordIndex & "/" & TotalRecordNum & """;" & vbCrLf
    End If
    Response.Write "</script>" & vbCrLf
    Response.Flush
End Sub


Function GetRecordNum(strTable)
    If strTable = "" Then
        GetRecordNum = 0
        Exit Function
    End If
    Dim nrs
    Set nrs = Conn_Old.Execute("select Count(*) from " & strTable)
    GetRecordNum = nrs(0)
    If IsNull(GetRecordNum) Then GetRecordNum = 0
    nrs.Close
    Set nrs = Nothing
End Function

Sub ErrorHandle(ErrTable, ErrRecord, EndUpdate)
    If Err.Number <> 0 Then
        Select Case Err.Number
        Case -2147217887
            If EndUpdate = 1 Then
                Response.Write "出错表：" & ErrTable & " 出错记录：" & ErrRecord & " 迁移失败，因为有相同ID的记录存在。请检查后重新迁移！<br>"
            Else
                Response.Write "出错表：" & ErrTable & " 出错记录：" & ErrRecord & " 此记录未迁移成功，因为有相同ID的记录存在。<br>"
            End If
        Case Else
            If IsObject(Conn) Then
                If Conn.Errors.Count > 0 Then
                    For i = 0 To Conn.Errors.Count - 1
                        Response.Write "错误类型：数据库错误<BR>"
                        Response.Write "错 误 号：" & Conn.Errors(i).Number & "<BR>"
                        Response.Write "错误描述：" & Conn.Errors(i).Description & "<BR>"
                        Response.Write "错误来源：" & Conn.Errors(i).Source & "<BR>"
                        'Response.Write "SQLState: " & conn.Errors(i).SQLState & "<BR>"
                        'Response.Write "NativeError: " & conn.Errors(i).NativeError & "<BR>"
                    Next
                End If
            Else
                If Err.Number <> 0 Then
                    Response.Write "错误类型：页面错误<BR>"
                    Response.Write "错 误 号：" & Err.Number & "<BR>"
                    Response.Write "错误描述：" & Err.Description & "<BR>"
                    Response.Write "错误来源：" & Err.Source & "<BR>"
                    'Response.Write "出 错 行：" & Err.Line & "<BR>"
                End If
            End If
        End Select
        Err.Clear
        If EndUpdate = 1 Then
            Response.End
        End If
    End If
End Sub


Sub DelAllCache()
    Dim Cacheobj, strAllCache, CacheList, i
    For Each Cacheobj In Application.Contents
        strAllCache = strAllCache & Cacheobj & ","
    Next
    CacheList = Split(strAllCache, ",")
    If UBound(CacheList) > 0 Then
        For i = 0 To UBound(CacheList)
            Application.Lock
            Application.Contents.Remove CacheList(i)
            Application.UnLock
        Next
    End If
End Sub

Function FoundInArr(strArr, strItem)
    Dim arrTemp, i
    FoundInArr = False
    arrTemp = Split(strArr, ",")
    For i = 0 To UBound(arrTemp)
        If LCase(Trim(arrTemp(i))) = LCase(Trim(strItem)) Then
            FoundInArr = True
            Exit For
        End If
    Next
End Function

Function GetNewID(ArrID, OldID)
    Dim i
    If OldID = 0 Or IsNull(OldID) Then
        GetNewID = 0
        Exit Function
    End If
    GetNewID = OldID
    For i = 0 To UBound(ArrID)
        If ArrID(i, 0) = PE_CLng(OldID) Then
            GetNewID = ArrID(i, 1)
            Exit Function
        End If
    Next
End Function

Function PE_CLng(ByVal str1)
    If IsNumeric(str1) Then
        PE_CLng = CLng(str1)
    Else
        PE_CLng = 0
    End If
End Function

Function PE_CDate(ByVal str1)
    If IsDate(str1) Then
        PE_CDate = CDate(str1)
    Else
        PE_CDate = Now
    End If
End Function

Function PE_CBool(ByVal bool1)
    If Not IsNull(bool1) Then
        PE_CBool = CBool(bool1)
    Else
        PE_CBool = False
    End If
End Function



%>