|
|
|
import file excel ไม่ได้ครับ คือผมทำแบบนี้แล้วแต่มันไม่เข้าแล้วก็ไม่ไปไหนเลยครับ |
|
|
|
|
|
|
|
คือผมทำแบบนี้แล้วแต่มันไม่เข้าแล้วก็ไม่ไปไหนเลยครับ ขอผู้รู้ช่วยตอบทีครับ
Code (ASP)
<% Option Explicit %>
<html>
<head>
<title>HINO Motors (Thailand) Ltd./title>
</head>
<!--#include file ="conn.asp"-->
<!--#include file ="checkuser.asp"-->
<body>
<%
Dim xlApp,xlBook,xlSheet1,xlSheet2,OpenFile,i
Dim Conn,strSQL,objExec
Dim mySmartUpload
Dim sFileName
'*** Upload By aspSmartUpload ***'
'*** Create Object ***'
Set mySmartUpload = Server.CreateObject("aspSmartUpload.SmartUpload")
'*** Upload Files ***'
mySmartUpload.Upload
'** Getfile Name ***'
sFileName = mySmartUpload.Files("file1").FileName
If sFileName <> "" Then
mySmartUpload.Files("file1").SaveAs(Server.MapPath("MyXls/"&sFileName))
OpenFile = "MyXls/"&sFileName
'*** Create Exce.Application ***'
Set xlApp = Server.CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Open(Server.MapPath(OpenFile))
Set xlSheet1 = xlBook.Worksheets(1)
'***Set Conn = Server.Createobject("ADODB.Connection")***'
'***Conn.Open "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("MyXls/mydatabase.mdb"),"" , ""***'
status_admin="N"
For i = 2 To 5
If Trim(xlSheet1.Cells.Item(i,1)) <> "" Then
Sql = "Select * From MsEmployee " & _
" Where Employee_code = '"&xlSheet1.Cells.Item(i,1)&"' "
Set RsDiv=Server.CreateObject("ADODB.RecordSet")
RsDiv.CursorLocation=3
RsDiv.open Sql,Conn,,,adcmdText
If RsDiv.Eof Then
strSQL = ""
strSQL = strSQL &"INSERT INTO MsEmployee "
strSQL = strSQL &"(Employee_code,Department_code,F_Locat_ID,F_Title,F_Name,F_Surname,F_Title_En,Name,Surname) "
strSQL = strSQL &"VALUES "
strSQL = strSQL &"('"&xlSheet1.Cells.Item(i,1)&"','"&xlSheet1.Cells.Item(i,2)&"', '"&xlSheet1.Cells.Item(i,3)&"' "
strSQL = strSQL &",'"&xlSheet1.Cells.Item(i,4)&"','"&xlSheet1.Cells.Item(i,5)&"', '"&xlSheet1.Cells.Item(i,6)&"') "
strSQL = strSQL &",'"&xlSheet1.Cells.Item(i,7)&"','"&xlSheet1.Cells.Item(i,8)&"', '"&xlSheet1.Cells.Item(i,9)&"') "
Conn.Execute strSQL
Sql = "Insert into MsUser(User_Name, Password_ID, Employee_Code, Level_Auth)" & _
"Values('"& xlSheet1.Cells.Item(i,1) &"','" & ***** & "','"& xlSheet1.Cells.Item(i,1) &"'," & _
"'" & status_admin & "')"
Conn.Execute Sql
Sql = "Select * From T_all " & _
" Where Employee_code = '"&xlSheet1.Cells.Item(i,1)&"' "
Set RsDiv1=Server.CreateObject("ADODB.RecordSet")
RsDiv1.CursorLocation=3
RsDiv1.open Sql,Conn,,,adcmdText
For i = 1 to RsDiv1.RecordCount
Sql = "Insert into MsAuth_report(Employee_Code, report_number)" & _
"Values('"& xlSheet1.Cells.Item(i,1) &"','" & RsDiv1("report_number") & "')"
Conn.Execute Sql
RsDiv1.MoveNext
Next
end if
End IF
Next
<br>
<div align="center">
<font name="Tahoma" size="2px" color="#C00000"><b>
Add User is ok. !!!!</b></font>
</font>
</div>
xlApp.Application.Quit
'*** Quit and Clear Object ***'
Conn.Close()
Set Conn = Nothing
Set xlSheet1 = Nothing
Set xlBook = Nothing
Set xlApp = Nothing
End If
Set mySmartUpload = Nothing
%>
</body>
</html>
Tag : - - - -
|
|
|
|
|
|
Date :
2010-06-17 16:47:41 |
By :
juka |
View :
1515 |
Reply :
5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุณครับ Mr. WIN เดี๋ยวจะลองปรับดูนะครับ
|
|
|
|
|
Date :
2010-06-18 08:41:21 |
By :
juka |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ลองทำแล้วครับแต่มันขึ้นแบบนี้อ่ะครับ ตามรูป
|
|
|
|
|
Date :
2010-06-18 09:08:10 |
By :
juka |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอความช่วยเหลือทีครับ
|
|
|
|
|
Date :
2010-06-21 08:25:55 |
By :
juka |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เพิ่มเติมนะครับตอน aspSmartUpload ผมใช้แบบนี้นะครับ
Code (ASP)
<html>
<head>
<title>HINO Motors (Thailand) Ltd.</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874">
</head>
<body bgcolor="#ffffff" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="">
<form action="Admin_User_Import_01.asp" method="post" enctype="multipart/form-data" name="frmMain">
<font color="#c60000" size="4" name="Tahoma"><b><u>Administrator</u></b></font>
<table width="100%" align="center" border="0">
<tr>
<td>
<table borderColor="#cccccc" cellSpacing="0" width="100%" border="1">
<tr bgColor="#a00000">
<td>
<table width="100%" border="0">
<tr bgColor="#a00000">
<td align="leftr"><font color="#ffffff" size="4" name="Tahoma">Import
New User</font> </td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="423">
<table width="100%" border="0">
<tr>
<td width="32%" align="right"><font face="tahoma" color="#c00000" size="2"><b>Import
File :</b></font></td>
<td width="68%"><input name="file1" type="file">
<input type="submit" name="Submit" value="Submit">
<font face="tahoma" color="#c00000" size="2"><b>(*.csv) </b></font>
</td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</body>
</html>
|
|
|
|
|
Date :
2010-06-21 10:53:24 |
By :
juka |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|