| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 428 人关注过本帖
标题:[求助]如何判断两个ID和名称是否一致
只看楼主 加入收藏
hbsxxmm
Rank: 1
等 级:新手上路
帖 子:16
专家分:0
注 册:2006-2-18
收藏
 问题点数:0 回复次数:1 
[求助]如何判断两个ID和名称是否一致

数据库有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
%>

搜索更多相关主题的帖子: 名称 判断 
2006-04-09 21:23
hbsxxmm
Rank: 1
等 级:新手上路
帖 子:16
专家分:0
注 册:2006-2-18
收藏
得分:0 
我这样做的话!就不在同一表格,还有就是数据库ID全部都显示出来了!我只要求显示与EXCEL  ID相同的!
2006-04-09 21:25
快速回复:[求助]如何判断两个ID和名称是否一致
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.024638 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved