excel表格上传并导入sql,如数据大,并有多个客户同时上传,应该如何处理呢?
请问,我用ASP做了上传excel表格并加到sql里,如果同时有很多客户端上传,或excel比较大时,应该怎么处理呢?用存储过程?应该怎么写代码呢?下面是我用ASP的代码:
DIM id,rs1,sql,connXLS,rsXLS,iXLS
iXLS=0
Set connXLS = Server.CreateObject("ADODB.Connection")
connXLS.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & FSPath&FileName & ";Extended Properties=Excel 8.0"
Set rsXLS = Server.CreateObject("ADODB.Recordset")
rsXLS.Open "SELECT * FROM [Sheet1$]", connXLS, 2, 2
id=session("id")
set rs1=server.createobject("adodb.recordset")
rs1.open "select * from stock where gsid='"&id&"'",conn,1,3
IF Not (RS1.EOF And Rs1.Bof) THEN
sql="delete from stock where gsid="&id&""
conn.execute sql
end if
IF RsXLS.Eof And RsXLS.Bof Then
Response.write "没有找到您需要的数据!!"
Else
While Not RsXLS.EOF
'导入开始
rs1.addnew
rs1("Part")=trim(RsXLS(0))
rs1("Mfg")=trim(RsXLS(1))
rs1("Qty")=trim(RsXLS(2))
rs1("DC")=trim(RsXLS(3))
rs1("Package")=trim(RsXLS(4))
rs1("Descrption")=trim(RsXLS(5))
rs1("Price")=trim(RsXLS(6))
rs1("Gsid")=session("id")
rs1("Datetime")=trim(RsXLS(7))
rs1.update
'导入结束
iXLS=iXLS+1
RsXLS.MoveNext
Wend
End IF