<% On Error Resume Next Dim Conn,ConnStr Dim Rs,SQL,i,n ConnStr = Session("ConnData") Set Conn = Server.CreateObject("ADODB.Connection") Conn.Open Connstr If Err Then Err.Clear Set Conn = Nothing Response.Write ("

数据库连接出错，
请检查您的数据库连接是否正确。

") Session("ConnData") = "" Response.End End If Dim totalnumber,num,p totalnumber = ChkNumeric(Request("total")) num = ChkNumeric(Request("num")) If num = 0 Then num = 1 p = ChkNumeric(Request("p")) If p = 0 Then p = 1 Call UpdateSoftData() If IsObject(Conn) Then Conn.Close Set Conn = Nothing End If Sub Progress() Response.Write "

" & vbNewLine Response.Write "
" & vbNewLine Response.Write "
正在更新数据库，请稍候... " & vbNewLine Response.Write "
" & vbNewLine Response.Write "
" & vbNewLine Response.Write "

" & vbNewLine Response.Write "
" & vbNewLine Response.Write "

" & vbNewLine Response.Write "

" & vbNewLine Response.Write "

" & vbNewLine Response.Write "

" & vbNewLine Response.Write "
" & vbNewLine Response.Write "
" & FormatNumber(num*50 / totalnumber * 100, 2, -1) & " % " & vbNewLine Response.Write "
" & vbNewLine Response.Write "

" & vbNewLine Response.Flush Response.Write "" Response.Flush End Sub Sub UpdateSoftData() If totalnumber = 0 Then totalnumber = Conn.Execute("SELECT Count(softid) FROM [NC_SoftList] WHERE IsUpdate=1")(0) End If If totalnumber Mod 50 = 0 Then n = totalnumber \ 50 Else n = totalnumber \ 50 + 1 End If If num > n Then Response.Write "

数据库全部升级完成，请关闭本窗口，然后用ACCESS“压缩和修复数据库”再上传到WEB空间

" & vbNewLine Session("ConnData") = "" Exit Sub End If On Error Resume Next Set Rs = Server.CreateObject("ADODB.Recordset") SQL = "SELECT TOP 50 softid,ChannelID,DownAddress FROM NC_SoftList WHERE IsUpdate=1 ORDER BY softid" Rs.Open SQL,Conn,1,1 If Rs.BOF And Rs.EOF Then Response.Write "数据库全部转换完成" & vbNewLine Exit Sub Else Do While Not Rs.EOF FormatAddress Rs("softid"),Rs("ChannelID"),Rs("DownAddress") Conn.Execute("UPDATE NC_SoftList SET DownAddress='',isUpdate=0 WHERE softid=" & Rs(0)) Rs.movenext Loop Call Progress() Response.Flush End If Rs.Close:Set Rs = Nothing End Sub Sub FormatAddress(softid,ChannelID,str) Dim FullAddress,AddressNum FullAddress = str Dim ArrayFullAddress,ArrayDownAddress,ArrayDownSiteName On Error Resume Next If Len(FullAddress) > 5 Then ArrayFullAddress = Split(FullAddress, "|||") ArrayDownAddress = Split(ArrayFullAddress(1), "|") ArrayDownSiteName = Split(ArrayFullAddress(0), "|") If UBound(ArrayDownAddress) < UBound(ArrayDownSiteName) Then AddressNum = UBound(ArrayDownAddress) Else AddressNum = UBound(ArrayDownSiteName) End If For i =0 To AddressNum If ArrayDownAddress(i) <> "" And ArrayDownSiteName(i) <> "" Then addDownAddress ChannelID,softid,0,Left(ArrayDownAddress(i),252),Left(ArrayDownSiteName(i),252) End If Next End If End Sub Sub addDownAddress(ChannelID,softid,downid,strAddress,downtext) On Error Resume Next If Len(downtext)=0 Then downtext = "立即下载" If Len(strAddress)=0 Then Exit Sub strAddress = Left(strAddress,250) downtext = Left(downtext,250) If softid = 0 Then Exit Sub SQL = "Insert Into NC_DownAddress (ChannelID,softid,downid,DownFileName,downtext) values (" & ChannelID & "," & softid & "," & downid & ",'" & Replace(strAddress, "'", "") & "','" & Replace(downtext, "'", "") & "')" Conn.Execute(SQL) End Sub Function ChkNumeric(ByVal CHECK_ID) If CHECK_ID <> "" And IsNumeric(CHECK_ID) Then CHECK_ID = CLng(CHECK_ID) If CHECK_ID < 0 Then CHECK_ID = 0 Else CHECK_ID = 0 End If ChkNumeric = CHECK_ID End Function %>