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 > ช่วยดู code ให้หน่อยค่ะ ต้องการที่จะ upload file ลงฐานข้อมูล



 

ช่วยดู code ให้หน่อยค่ะ ต้องการที่จะ upload file ลงฐานข้อมูล

 



Topic : 043315

Guest




ช่วยดู code ให้หน่อยค่ะ ต้องการที่จะ upload file ลงฐานข้อมูล
ถ้าเขียน file ลงฐานข้อมูลตรงๆอะได้ค่ะ แต่ถ้าต้องการ upload file ลงไปในฐานข็อมูล
ต้องเขียนอย่างไรค่ะ
ตรง upload ค่ะ ช่วยดูให้หน่อยน่ะค่ะ


Code (ASP)
<% Option Explicit %>

  <html>
  <head>
  <title>Importdatatotextfile</title>
  </head>
  <body>
			<% 
 			Dim  conn, fs, objFile, objFileTextStream, i, strSQL 
			Dim  strLine, strLinePart, strFirstName
			Dim  Posting,Document_Header_Text,Material,Material_Description
			Dim  Qty_in_Un_Of_Entry,Unit_of_Entry,Batch,Cost_Center,Movement_Type
			Dim  Storage_Location,Material_Document,Special_Stock,Vendor
			Dim  Amount_in_LC,GL_Account
			
			Dim mySmartUpload
			'*** Upload By aspSmartUpload ***' 

			'*** Create Object ***'  
   
			Set mySmartUpload = Server.CreateObject("Upload.SmartUpload") 
 

			'*** Upload Files ***' 
    
			mySmartUpload.Upload 

 
			'** Getfile Name ***' 
 
			sFileName = mySmartUpload.Files("file1").FileName 
 
 
                If sFileName <> "" Then
        
               '*** Upload **' 
       
			mySmartUpload.Files("file1").SaveAs(Server.MapPath("txt/"&sFileName)) 
 
            OpenFile = "txt/"&sFileName 
			
			'*** Create Object ***' 
        
			Set objFSO = CreateObject("Scripting.FileSystemObject")  
 
 
			'*** Check Exist Files ***' 
        
		If Not objFSO.FileExists(Server.MapPath(sFileName)) Then
            
		
       
			Else
			
 '*** Open Files ***' 
        
			Set oInStream = objFSO.OpenTextFile(Server.MapPath(sFileName),1,False) 
				
				
			SET CONN = SERVER.CREATEOBJECT("ADODB.CONNECTION")
	
		    CONN.OPEN "Provider=SQLOLEDB.1;Data Source=192.1.10.58;Initial Catalog=SAP_MM;User ID=nok;Pwd=nok"

 				
				Set fs = Server.CreateObject("Scripting.FileSystemObject") 

 				'Set objFile = fs.GetFile("C:\SAP_GI_1.txt") 
				'Set objFile = fs.GetFile(Server.MapPath(openFile)) 
 				
              Set objFileTextStream = objFile.OpenAsTextStream(1) 
			    

 				objFileTextStream.skipLine 

				 Do While objFileTextStream.AtEndOfStream <> True 
   				strLine = objFileTextStream.ReadLine 
   				strLinePart = split(strLine,"	") 
   				for i = 0 TO UBound(strLinePart) 
				
     			If i = 0 Then 
				Posting = Trim(strLinePart(i))
				ElseIf i = 1 Then
       			Document_Header_Text = Trim(strLinePart(i)) 
     			ElseIf i = 2 Then 
       			Material = Trim(strLinePart(i)) 
     			ElseIF i = 3 Then 
       			Material_Description = Trim(strLinePart(i)) 
				ElseIF i = 4 Then 
       			Qty_in_Un_Of_Entry = Trim(strLinePart(i)) 
			     
				ElseIF i = 5 Then 
       			Unit_of_Entry = Trim(strLinePart(i)) 
			    ElseIF i = 6 Then 
       			Batch = Trim(strLinePart(i))
			
			    ElseIF i = 7 Then 
       			Cost_Center = Trim(strLinePart(i))
				
				ElseIF i = 8 Then 
       			Movement_Type = Trim(strLinePart(i))
				
				ElseIF i = 9 Then 
       			Storage_Location = Trim(strLinePart(i))
				
				ElseIF i = 10 Then 
       			Material_Document = Trim(strLinePart(i))
				
				ElseIF i = 11 Then 
       			Special_Stock = Trim(strLinePart(i))
				
				ElseIF i = 12 Then 
       			Vendor = Trim(strLinePart(i))
			
			    ElseIF i = 13 Then 
       			Amount_in_LC = Trim(strLinePart(i))
			
			    ElseIF i = 14 Then 
       			GL_Account = Trim(strLinePart(i))
				
     			End If 
   				Next   


   			'intPosting_Date = Trim(intPosting_Date) 

   			strSQL = "INSERT INTO SAP_GI  ([Posting_Date],[Document_Header_Text],[Material],[Material_Description],[Qty_in_Un_Of_Entry],[Unit_of_Entry],[Batch],[Cost_Center],[Movement_Type],[Storage_Location],[Material_Document],[Special_Stock],[Vendor],[Amount_in_LC],[GL_Account]) "
			
			strSQL = strSQL &"	VALUES "
			
			strSQL = strSQL &"		('"&Posting&"','"&Document_Header_Text&"','"&Material&"','"&Material_Description&"','"&Qty_in_Un_Of_Entry &"'"
			strSQL = strSQL &"      ,'"& Unit_of_Entry &"','" &Batch&"','"&Cost_Center&"','"&Movement_Type&"'"
			strSQL = strSQL &"      ,'"& Storage_Location &"','"&Material_Document&"','"&Special_Stock&"','"&Vendor&"'"
			strSQL = strSQL &"      ,'"& Amount_in_LC&"','"&GL_Account&"')"
			
			
			'response.write(strSQL)
			conn.Execute strSQL 
 			Loop 

 			objFileTextStream.Close: Set objFileTextStream = Nothing 
 			Set fs = Nothing 
 			conn.Close: Set conn = Nothing 

		%>




Tag : - - - -







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2010-05-26 08:51:15 By : nok View : 1289 Reply : 1
 

 

No. 1

Guest





Go to : ASP aspSmartUpload - Upload files to Database






Date : 2011-09-18 17:03:06 By : thaicreate
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : ช่วยดู code ให้หน่อยค่ะ ต้องการที่จะ upload file ลงฐานข้อมูล
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ 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 อัตราราคา คลิกที่นี่