Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > ASP > ASP Forum > import file excel ไม่ได้ครับ คือผมทำแบบนี้แล้วแต่มันไม่เข้าแล้วก็ไม่ไปไหนเลยครับ



 

import file excel ไม่ได้ครับ คือผมทำแบบนี้แล้วแต่มันไม่เข้าแล้วก็ไม่ไปไหนเลยครับ

 



Topic : 044167



โพสกระทู้ ( 38 )
บทความ ( 0 )



สถานะออฟไลน์




คือผมทำแบบนี้แล้วแต่มันไม่เข้าแล้วก็ไม่ไปไหนเลยครับ ขอผู้รู้ช่วยตอบทีครับ

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 : - - - -







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2010-06-17 16:47:41 By : juka View : 1458 Reply : 5
 

 

No. 1



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

ลองเอาตัวอย่างไปดูแล้วค่อย ๆ ปรับแก้ไขก็น่าจะได้น่ะครับ


ASP Import Excel to Database (Excel.Application)






Date : 2010-06-17 22:28:47 By : webmaster
 


 

No. 2



โพสกระทู้ ( 38 )
บทความ ( 0 )



สถานะออฟไลน์


ขอบคุณครับ Mr. WIN เดี๋ยวจะลองปรับดูนะครับ
Date : 2010-06-18 08:41:21 By : juka
 

 

No. 3



โพสกระทู้ ( 38 )
บทความ ( 0 )



สถานะออฟไลน์


ลองทำแล้วครับแต่มันขึ้นแบบนี้อ่ะครับ ตามรูป

error upload import
Date : 2010-06-18 09:08:10 By : juka
 


 

No. 4



โพสกระทู้ ( 38 )
บทความ ( 0 )



สถานะออฟไลน์


ขอความช่วยเหลือทีครับ
Date : 2010-06-21 08:25:55 By : juka
 


 

No. 5



โพสกระทู้ ( 38 )
บทความ ( 0 )



สถานะออฟไลน์


เพิ่มเติมนะครับตอน 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">
&nbsp; <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">&nbsp;</td>
                </tr>
              </table>
								    </td>
							</tr>
						</table>
					</td>
				</tr>
			</table>

	 </form>
</body>
</html>

Date : 2010-06-21 10:53:24 By : juka
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : import file excel ไม่ได้ครับ คือผมทำแบบนี้แล้วแต่มันไม่เข้าแล้วก็ไม่ไปไหนเลยครับ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 01
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่