28,390
社区成员
发帖
与我相关
我的任务
分享
<FORM METHOD=POST ACTION="FileUp.asp" >
<table width="323" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="15"><img src="../image/p_2.gif" alt=";;" width="15" height="11" /></td>
<td width="259"><font size="2" color="#660000"></a>
<input name="path" type="file" value="" size="25" />
</font></td>
<td width="86"><font size="2" color="#660000"></a></font><font size="2" color="#660000">
<input type="submit" name="dr" value="导入" />
</font></td>
</tr>
<tr>
<td> </td>
<td><span class="STYLE4"><font size="2" color="#660000">导入信息表</font></span></td>
<td> </td>
</tr>
</table>
</form>
<%
dim AllText,strLine,sql,mysql
dim strpath,fileurl
fileurl=""
strpath=Trim(Request.form("path")) '获取文本文件路径
fileurl=strpath
SET FSO=CreateObject("Scripting.FileSystemObject")
SET ATextStream=FSO.OpenTextFile(fileurl,1,false,TristateFalse)
'''''''''提取数据开始'''''''''''''''
ATextStream.ReadLine() '跳过一行(列名),从第二行开始读取
Do While ATextStream.AtEndOfStream <> True
Lines = Atextstream.readline
strLine=split(Lines," ")
'然后根据数组0的值去判断在数据库里面是否存在,在执行接下来的语句!
Set rs=Server.CreateObject("Adodb.RecordSet")
sql="select * from Q_user where supplier_code='"&strLine(0)&"'"
rs.open sql,conn,1,1
if not(rs.bof and rs.eof) then
sql="update Q_user set MEM_NAME='"&strLine(1)&"' where supplier_code='"&strLine(0)&"'"
else
sql="insert into Q_user(SUPPLIER_CODE,MEM_NAME,PASSWORD,LEVEL) values ('"&strLine(0)&"','"&strLine(1)&"','"&strLine(2)&"','"&strLine(3)&"')"
end if
Conn.Execute sql
loop
Atextstream.close
response.write "<br>"+"您已经成功录入数据数据!<a href=admin.asp>[继续导入]</a><br>"
rs.close
conn.close
set rs=nothing
set Conn=nothing
set FSO=nothing
' set ATextStream=nothing
%>
response.write "Start All Location infomation At:" & Now() & "<Br>"
Call ProcessAllLocation(Path)
'将生成的tmp.txt 导入到数据库
SQL = "INSERT INTO AllLocation(Location,Aisle,Pick,Putaway,CheckCode,Used,Type,Weight,Width,Depth,Height)"
SQL = SQL & " select * from OpenRowset('MSDASQL','Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq=" & Server.MapPath(".") & ";Extensions=asc,csv,tab,txt;'"
SQL = SQL & ",'select * from abc.txt')"
Conn.execute(Sql)
response.write "<Br>End At:" & Now() & "<Br>"
<%
set fs=server.createobject "scripting.fileSystemObject ")
File = Server.MapPath( "1.txt ")
Set txt=fso.OpenTextFile(File)
If Not txt.atEndOfStream Then
Lines = txt.readline
rs.addnew
rs("a")=Lines
rs.update
End If
Txt.close
%>