|
|
|
csv upload ขอวิธีแก้หน่อยค่ะเวลารับค่าจากฟอร์ม ตรง Server.MapPath มันเออเรอนะคะจะแก้ยังไง |
|
|
|
|
|
|
|
ขอวิธีแก้หน่อยค่ะเวลารับค่าจากฟอร์ม ตรง Server.MapPath มันเออเรอนะคะจะแก้ยังไง
Code (ASP)
<%Option Explicit%>
<html>
<head>
<title>ThaiCreate.Com ASP & Import CSV To Access</title>
</head>
<body>
<%
Dim objFSO,oInStream,sRows,arrRows
Dim Conn,strSQL,objExec
Dim sFileName
sFileName = "customer.csv"
'*** Create Object ***'
Set objFSO = CreateObject("Scripting.FileSystemObject")
'*** Check Exist Files ***'
If Not objFSO.FileExists(Server.MapPath(sFileName)) Then
Response.write("File not found.")
Else
'*** Open Files ***'
Set oInStream = objFSO.OpenTextFile(Server.MapPath(sFileName),1,False)
'*** open Connect to Access Database ***'
Set Conn = Server.Createobject("ADODB.Connection")
Conn.Open "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("mydatabase.mdb"),"" , ""
Do Until oInStream.AtEndOfStream
sRows = oInStream.readLine
arrRows = Split(sRows,",")
'*** Insert to table customer2 ***'
strSQL = ""
strSQL = strSQL &"INSERT INTO customer2 "
strSQL = strSQL &"(CustomerID,Name,Email,CountryCode,Budget,Used) "
strSQL = strSQL &"VALUES "
strSQL = strSQL &"('"&arrRows(0)&"','"&arrRows(1)&"','"&arrRows(2)&"' "
strSQL = strSQL &",'"&arrRows(3)&"','"&arrRows(4)&"','"&arrRows(5)&"') "
Set objExec = Conn.Execute(strSQL)
Set objExec = Nothing
Loop
oInStream.Close()
Conn.Close()
Set oInStream = Nothing
Set Conn = Nothing
End If
Response.write ("CSV Import to Access Done.")
%>
</table>
</body>
</html>
Tag : ASP
|
|
|
|
|
|
Date :
2013-12-14 13:13:35 |
By :
des |
View :
1136 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Error ว่าอะไรครับ
|
|
|
|
|
Date :
2013-12-15 07:33:52 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|