本文采用Asp技術(shù)實(shí)現(xiàn)數(shù)據(jù)導(dǎo)入進(jìn)度狀態(tài)的顯示,代碼如下:
<!– #include file=”inc/dsn.asp” –>
<!–#include file=”inc/vbfun.asp”–>
<form name=”data” action=”” id=”data”>
<input name=”showdata” type=”text” value=”數(shù)據(jù)正在加載中…” size=”100″>
</form>
<script>
<%
excelurl=request.Form(“file_url”)
gz_year=request.Form(“gz_year”)
gz_month=request.Form(“gz_month”)
if gz_year=”” then
gz_year=year(now())
end if
if gz_month=”” then
gz_month=month(now())
end if
if excelurl<>”” then
set rs=server.CreateObject(“adodb.recordset”)
strexcel=”provider=Microsoft.Jet.OLEDB.4.0; Data Source=”&server.MapPath(excelurl)&”;Extended Properties=Excel 8.0″
set connexcel=CreateObject(“ADODB.Connection”)
connexcel.Open strexcel
Sql=”select * from [sheet1$]”
rs.Open Sql,connexcel
IF rs.Eof And Rs.Bof Then
response.Write(“alert (‘沒(méi)有資料可以導(dǎo)入!’);”)
else
Conn.BeginTrans
set rsf=server.CreateObject(“adodb.recordset”)
rsf.open(“select * from gz_infor where gz_year=”&gz_year&” and gz_month=”&gz_month&””) ,conn
if not rsf.eof then
response.write “alert(‘在這個(gè)月中您已經(jīng)導(dǎo)入了一次工資以免重復(fù)請(qǐng)核對(duì),該次操作作廢!’);</script>”
response.End()
end if
do while not rs.eof
%>
document.data.showdata.value=”<%=”用戶名:”&rs(1)&” 賬號(hào):”&rs(0)%>”;
<%
process=rs(0)
‘ On Error Resume Next
conn.execute(“importgz ‘”&rs(0)&”‘,'”&rs(1)&”‘,'”&rs(2)&”‘,'”&rs(3)&”‘,'”&rs(4)&”‘,'”&rs(5)&”‘,'”&rs(6)&”‘,'”&rs(7)&”‘,'”&rs(8)&”‘,'”&rs(9)&”‘,'”&rs(10)&”‘,'”&rs(11)&”‘,'”&rs(12)&”‘,'”&rs(13)&”‘,'”&rs(14)&”‘,'”&rs(15)&”‘,'”&rs(16)&”‘,'”&rs(17)&”‘,”&gz_year&”,”&gz_month)
if conn.Errors.Count>0 then
conn.Errors.Clear
conn.RollBackTrans
response.write “<script>alert(導(dǎo)入過(guò)程中出現(xiàn)錯(cuò)誤,該次操作作廢!’);history.back();</Script>”
response.End()
end if
rs.movenext
loop
Conn.CommitTrans
response.Write(“alert(‘成功導(dǎo)入用戶資料’);”)
end if
%>
document.data.showdata.value=”數(shù)據(jù)導(dǎo)入完畢”;
<%
else
%>
window.alert(“你沒(méi)有選擇任何文件”);
document.data.showdata.value=”你沒(méi)有選擇任何文件”;
<%
end if
%>
</script>