본문 바로가기
컴퓨터이야기/ASP&.NET

엑셀업로드해서 DB로 저장하기

by 변화지시자 2009. 11. 21.
반응형

< %
Set theForm = Server.CreateObject("ABCUpload4.XForm")
theForm.MaxUploadSize=524288000
Set theField = theForm("file_name")(1)

 dim dicElements, arrElements, arrValue
 dim rsTemp
 dim mMode
mMode= ""

title = theForm("title")

If theField.FileExists <> 0 Then
 'binData     = Dict.Item( sHTMLFormField).Item("Value")
 binData = theField.content
 'binData     = getString(binData)
 arrElements     = split(binData, chr(13) & chr(10))
 call OpenConnection
 SQL = "delete from measuredata where data_title = '"&title&"'"
 mobjConnection.Execute SQL

 for i = 0 to Ubound(arrElements)

  arrValue = split(arrElements(i), ",")
   fildCnt = 0
   for j = 0 to Ubound(arrValue)
    fildCnt = fildCnt+1
    
   next
   if fildCnt = 15 then
    SQL ="insert  measuredata(   "
    SQL =SQL & "data_date    "
    SQL =SQL & ",data_title     "
    SQL =SQL & ",sitename    "
    SQL =SQL & ",meachea    "
    SQL =SQL & ",chennel     "
    SQL =SQL & ",frequecy     "
    SQL =SQL & ",sitedist     "
    SQL =SQL & ",siteangle    "
    SQL =SQL & ",measure_value  "
    SQL =SQL & ",measure_quality  "
    SQL =SQL & ",sido      "
    SQL =SQL & ",gu,dong     "
    SQL =SQL & ",pointinfo     "
    SQL =SQL & ",x_coord     "
    SQL =SQL & ",y_coord     "
    SQL =SQL & ",profileurl)    "
    SQL =SQL & "values(     "
    SQL =SQL & "getdate(),     "
    SQL =SQL & "'"&trim(title)&"',"
    SQL =SQL & "'" & trim(arrValue(0)) & "',"
    SQL =SQL & "'" & trim(arrValue(1)) & "',"
    SQL =SQL & "'" & trim(arrValue(2)) & "',"
    SQL =SQL & "'" & trim(arrValue(3)) & "',"
    SQL =SQL & "'" & trim(arrValue(4)) & "',"
    SQL =SQL & "'" & trim(arrValue(5)) & "',"
    SQL =SQL & "'" & trim(arrValue(6)) & "',"
    SQL =SQL & "'" & trim(arrValue(7)) & "',"
    SQL =SQL & "'" & trim(arrValue(8)) & "',"
    SQL =SQL & "'" & trim(arrValue(9)) & "',"
    SQL =SQL & "'" & trim(arrValue(10)) & "',"
    SQL =SQL & "'" & trim(arrValue(11)) & "',"
    SQL =SQL &  trim(arrValue(12)) & ","
    SQL =SQL &  trim(arrValue(13)) & ","
    SQL =SQL & "'" & trim(arrValue(14)) & "')"

    mobjConnection.Execute SQL
   elseif fildCnt > 0 then
   %>
    < script language="javascript">
     alert("[<%=i+1%>]Line 파일 내용이 잘못 되었습니다");
     opener.OnList();
     location.href="./DtvFile.asp";
     
    </script>
   < %
   end if

 Next

%>