设为首页收藏本站

新微赢技术网

 找回密码
 注册
搜索
热搜: 回贴
查看: 33|回复: 1
打印 上一主题 下一主题

[求助]如何判断两个ID和名称是否一致

[复制链接]
跳转到指定楼层
1#
发表于 2010-1-14 07:42:46 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
数据库有ID、名称,EXCEL也有ID、名称,我希望在导入到数据库之前,先查看一下两个ID和名称是否一致,在导入,否则给予提示!该如何做到,还请高手给予指点!
数据库 ID NAME EXCEL ID NAME
1 矿业集团 1 矿业集团
2 北京 2 北京
3 上海 3 上海
4 南京

我的上传代码:
<!--#include file="../inc/conn.asp"-->
<!--#include FILE="upload_5xsoft.inc"-->
<html>
<head>
<title>文件上传</title>
<script language="javascript" src="ShowProcessBar.js"></script>
</head>
<body leftmargin="0" marginwidth="0" oncontextmenu="JavaScrip:return false" onselectstart="return true" oncopy="return true;" oncut="return true;" onpaste="return true">
</body>
<body>
<br>上传文件信息!<hr size=1 noshadow width=300 align=left><br><br>
<%set rsi=server.createobject("adodb.recordset")
rsi.open "select * from inc",conn,1,1
dx=cint(rsi("a7"))*1024
session("taxsh")=request("tax_no")
session("nsrid")=request("nsr_id")
dim upload,file,formName,formPath,iCount,filename,filenameend,filesize
set upload=new upload_5xsoft ''建立上传对象
set file=upload.file("file")
if upload.form("ssqtime")="" then
response.write"<SCRIPT language=JavaScript>alert('请选择所属期!');"
response.write"javascript:history.go(-1)</SCRIPT>"
response.end
else
filesize=FormatNumber(file.filesize/1024,1)
if file.fileSize<dx and file.fileSize>0 then
'自动生成文件名
filename=date()
filename=filename&time()
filename=replace(filename,"-","")
filename=replace(filename,":","")
filename=replace(filename," ","")
filename=filename+"."
filenameend=file.filename
filenameend=split(filenameend,".")
if filenameend(1)="xls" or filenameend(1)="XLS" then
filename=filename&filenameend(1)
file.saveAs Server.mappath("../upload/"&filename)
response.write "<br>"
response.write file.FilePath&file.FileName&"("&FileSize&" KB"&") 到 <font color=#FF0000> "&formPath&filename&"("&FileSize&" KB"&")</font>成功!<br>"
%>
<div align="center">
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="792" id="table1">
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<%set rsn=server.createobject("adodb.recordset")
rsn.open "select * from nsr_info order by nsrid",conn,1,1
while not rsn.eof
%>
<td><%=rsn("nsrid")%></td>
<% rsn.movenext
wend
dim conn2
set conn2=CreateObject("ADODB.Connection")
conn2.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath("..\upload\"&filename)&";Extended Properties=""Excel 5.0;HDR=no;"""
sql = "SELECT * FROM [Sheet1$]"
set rs = conn2.execute(sql)
while not rs.eof
%>
<td><%=fixsql(rs(1))%></td>
<td><%=fixsql(rs(2))%></td>
<td> </td>
</tr>
<%
rs.movenext

wend
%>
</table>
</div>
<%
conn.close
set conn = nothing
conn2.close
set conn2 = Nothing
response.write "<br>"
response.write "<br>[<a href=""sbbtext.asp?ssqtime="&upload.Form("ssqtime")&"&filename="&filename&"&tax_no="&session("taxsh")&"&nsr_id="&session("nsrid")&""" IsShowProcessBar=""True"">按此处导入</a>&nbsp;&nbsp;否则<a href=""sbbdeltext.asp?filename="&filename&"&tax_no="&session("taxsh")&"&nsr_id="&session("nsrid")&""">返回<a>]</body></html>"
response.end
set upload=nothing
set upload=nothing
set file=nothing
else
response.write "文件格式不对<a href='#' onclick='javascript:history.back();'>|返回|</a>"
end if
set file=nothing
else
response.write "文件不能大于"&rsi("a7")&"K<a href='#' onclick='javascript:history.back();'>|返回|</a>"
end if
end if
%>
</body>
</html>
<%
function fixsql(str)
dim newstr
newstr = str
'if isnull(newstr) then
'newstr = "0"
'else
'newstr = replace(newstr,"'","''")
'end if
fixsql = newstr
end Function
%>
您需要登录后才可以回帖 登录 | 注册

本版积分规则

申请友链|小黑屋|最新主题|手机版|新微赢技术网 ( 苏ICP备08020429号 )  

GMT+8, 2024-11-20 11:38 , Processed in 0.083913 second(s), 9 queries , Gzip On, Memcache On.

Powered by xuexi

© 2001-2013 HaiAn.Com.Cn Inc. 寰耽

快速回复 返回顶部 返回列表