<%@ Language=VBScript %>
<%
Server.ScriptTimeout = 99999
Response.Buffer = True
%>
<HTML>
<HEAD>
<Title>批量导入用户</Title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</HEAD>
<BODY>
<%
On Error Resume Next
If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
Dim strUserName, strUserTitle, strUserMail
Dim strPassword, strConfirmPassword
Dim flag_disabled, flag_cantchgpwd
Dim strErrorMsg
Dim userCnn
Set userCnn = Server.CreateObject("ADODB.Connection")
userCnn.Open Conn
' 链接Excel数据库
Dim excelCn,excelRs,excelSql,strFilePath,strCnn
strFilePath = Request.Form("myFile")
'strFilePath = Server.MapPath(".") & "\" & "teacher.xls"
Dim f,fso
Set fso = Server.CreateObject("Scripting.FileSystemObject")
If fso.FileExists(strFilePath) = False Then
Response.Write "文件:" & strFilePath & "在服务器上不存在。"
Response.End
End If
'strFilePath = Server.MapPath(".") & "\" & "teacher.xls"
strCnn = "DRIVER=Microsoft Excel Driver (*.xls);UID=admin;FIL=excel 8.0;DBQ=" & strFilePath
Set excelCn = Server.CreateObject("ADODB.Connection")
excelCn.Open strCnn
excelSql = "SELECT * FROM [Sheet1$]"
Set excelRs = excelCn.Execute(excelSql)
Dim i
i = 0
While Not excelRs.EOF
strUserName = Trim(excelRs("帐号"))
strUserTitle = Trim(excelRs("姓名"))
strPassword = Trim(excelRs("密码"))
strConfirmPassword = Trim(excelRs("密码"))
userCnn.Execute "INSERT tableName (帐号,姓名) VALUES('" & strUserName & "','" &strUserTitle& "')"
Set objUserProp = Nothing
Response.Write "<hr size=2 color=green>"
excelRs.MoveNext
i = i + 1
Response.Flush
Wend
userCnn.Close
excelCn.Close
Set userCnn = Nothing
Set excelCn = Nothing
Set excelRs = Nothing
Response.Write "共导入 " & i & " 个用户信息。"
Response.End
End If
%>
<%@ Language=VBScript %>
<%
Server.ScriptTimeout = 99999
Response.Buffer = True
%>
<HTML>
<HEAD>
<Title>批量导入用户</Title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</HEAD>
<BODY>
<%
On Error Resume Next
If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
Dim strUserName, strUserTitle, strUserMail
Dim strPassword, strConfirmPassword
Dim flag_disabled, flag_cantchgpwd
Dim strErrorMsg
Dim userCnn
Set userCnn = Server.CreateObject("ADODB.Connection")
userCnn.Open Conn
' 链接Excel数据库
Dim excelCn,excelRs,excelSql,strFilePath,strCnn
strFilePath = Request.Form("myFile")
'strFilePath = Server.MapPath(".") & "\" & "teacher.xls"
Dim f,fso
Set fso = Server.CreateObject("Scripting.FileSystemObject")
If fso.FileExists(strFilePath) = False Then
Response.Write "文件:" & strFilePath & "在服务器上不存在。"
Response.End
End If
'strFilePath = Server.MapPath(".") & "\" & "teacher.xls"
strCnn = "DRIVER=Microsoft Excel Driver (*.xls);UID=admin;FIL=excel 8.0;DBQ=" & strFilePath
Set excelCn = Server.CreateObject("ADODB.Connection")
excelCn.Open strCnn
excelSql = "SELECT * FROM [Sheet1$]"
Set excelRs = excelCn.Execute(excelSql)
Dim objUser
Set objUser = uctx.createUmgrObject("UserMgr.User")
Dim uLogic
Set uLogic = uctx.createUmgrObject("UserMgr.Logic")
Dim objLogic
Set objLogic = CreateSQLPUBObject("SQLPUB.PubLogic")
Dim i
i = 0
While Not excelRs.EOF
strUserName = Trim(excelRs("帐号"))
strUserTitle = Trim(excelRs("姓名"))
strPassword = Trim(excelRs("密码"))
strConfirmPassword = Trim(excelRs("密码"))
userCnn.Execute "INSERT tableName (帐号,姓名) VALUES('" & strUserName & "','" &strUserTitle& "')"
Set objUserProp = Nothing
Response.Write "<hr size=2 color=green>"
excelRs.MoveNext
i = i + 1
Response.Flush
Wend
userCnn.Close
excelCn.Close
Set objLogic = Nothing
Set userCnn = Nothing
Set excelCn = Nothing
Set excelRs = Nothing
Response.Write "共导入 " & i & " 个用户信息。"
Response.End
End If
%>