: ... ... ... % server.scripttimeout=100000000 sub dataIntoSqlServer_ceritificate(strFileName,strSheetName,myConn) '定义 dim myConnection dim strName dim rsXsl,rsSql dim str_Xsl,str_Sql dim myConn_Xsl dim cmd dim i,j dim maxId
strName=strFileName set myConnection=server.createobject("adodb.connection") set rsXsl=Server.Createobject("ADODB.Recordset") set rsSql=Server.CreateObject("ADODB.Recordset") set cmd=Server.CreateObject("ADODB.Command") cmd.ActiveConnection=myConn
'打开表 str_Xsl="select * from [" strSheetName "$]" rsXsl.open str_Xsl,myConnection,1,1 j=1 Do While not rsXsl.eof '取出最大值 str_Sql="select Max(id) as maxId from fubiao" rsSql.open str_Sql,myConn,1,3 If Not rsSql.Eof Then If not isNull(rsSql("maxId")) Then maxId=Clng(rsSql("maxId"))+1 Else maxId=1 End if else maxId=1 End if rsSql.close'//关闭对象 '加入数据库 str_Sql="insert into fubiao values("maxId",'"rsXsl(1)"','"rsXsl(3)
.br/>" response.write "a href=javascript:history.back()>确定/a>" set rsXsl=nothing set rsSql=nothing set myconnection=nothing set cmd=nothing end sub ... ... ... file1=request.form("filename2") strtj=mid(request.form("filename2"),instrrev(file1,"\")+1,(instrrev(file1,".")-
instrrev(file1,"\")-1)) if file1="" then response.write "请选择您要导入的Excel表!p>/p>" %> a href=javascript:history.back()>上一页/a> % response.end end if myconn="DRIVER={SQL SERVER};SERVER=(local);uid=sa;pwd=sa;DATABASE=qjgsj_data" call dataIntoSqlServer_ceritificate file1,""strtj"",myconn ... ... %> 在打开连接时: myConnection.open myConn_Xsl