|
If Request.QueryString("action")="do" Then
Dim conn
Dim StrConn
Dim Rs
Dim Sql
Dim i
Dim ExName
ExName = Request.Form("ExName")
ExTName = Request.Form("ExTName")
Set conn =Server.CreateObject("ADODB.Connection")
StrConn="Driver={Microsoft Excel Driver (*.xls)};DBQ="& Server.MapPath("Excel/"&ExName)
conn.Open StrConn
Set rs = Server.CreateObject("ADODB.Recordset")
Sql="select * from ["&ExTName&"$]"
rs.Open Sql,conn,1,1
%>
<br>
<form method=post action="JaAcc_Save.Asp" name=form1 onSubmit="return chk(this)">
<table width="100%" border="1" align=center cellspacing=1 bgcolor=#6699CC>
<tr align=center height=20 bgcolor=#6699CC style=color:white>
<td colspan="3">导入数据列表(请确保字段没有错误)</td>
</tr>
<td align="center">
<input name=Count type=hidden value="<%=rs.Fields.Count%>">
<%
for i=0 to rs.Fields.Count-1
%>
<input name=ExFName<%=i%> value="<%=Rs(i).Name%>" size="8"><%
Next
Response.Write "</td></tr></table><table width=100% border=1 align=center cellspacing=1 bgcolor=#6699CC>"
Response.Write "<tr bgcolor=white><td align=center>"
Dim a
a=0
do while not rs.eof
for i=0 to rs.Fields.Count-1
if i mod rs.Fields.Count = 0 then
Response.Write "<br>"
End if
%>
<input name=ExCName<%=a%> value="<%=Rs(i)%>" size="8">
<%
a = a +1
next
rs.MoveNext
Loop
Response.Write "</td></tr><tr><td align=center><input name='A' type=hidden value="&a&"><input type=submit value=导入数据></td></tr></table>"
Response.Write "</form>"
rs.close
set rs=nothing
conn.close
set StrConn=nothing
Response.End
End if
%>
<style>
td,input,select,textarea,body{font-size:9pt}
a{color:blue}
a:hover{color:green}
</style>
<script language="JavaScript" type="text/JavaScript">
function chk()
{
if (document.form1.ExName.value=="")
{
alert("Excel文件名称不能为空!");
document.form1.ExName.focus();
return false;
}
if (document.form1.ExTname.value=="")
{
alert("Excel数据表文件名称不能为空!");
document.form1.ExTname.focus();
return false;
}
}
</script>
<br>
<table width="500" align=center cellpadding=5 cellspacing=1 bgcolor=#006699>
<tr bgcolor=#6699CC style=color:white align=center>
</tr>
</table>
<form method="post" action="upload2.asp" enctype="multipart/form-data" name="form2">
<table width="500" align=center cellpadding=5 cellspacing=1 bgcolor=#006699>
<tr bgcolor=#6699CC style=color:white align=center>
<td>
<p align="left">
<b>
<font size="3"> 导入数据注意事项</font></b><br>
1:请确保你清楚Excel文件内容字段与导入数据库的字段相同</p>
<p align="left">
2:请确保你清楚Excel文件的表名正确 如 Sheet1<p align="left">
3:请确保服务器上有该Excel文件存在,如没有,请上传并记下文件名称<p align="left">
& |
|