6 Replies Latest reply on Jun 30, 2009 9:29 AM by JR "Bob" Dobbs-qSBHQ2

    error for the uploading csv file to database

    cfnew Level 1

      Hi i tried to upload the csv file to database and i am getting error as

      <cffile action="read" file="#data_dir_upload#/di_audit_corp_upc_ldr_tbl.csv" variable="di_audit_corp_upc_ldr_tbl">
      <!--- loop through the CSV-TXT file on line breaks and insert into database --->
      <cfloop index="index" list="#di_audit_corp_upc_ldr_tbl#" delimiters="#chr(10)##chr(13)#">
          <cfquery  datasource="#request.dsnCAO#">   
                  <!--- SET ANSI_WARNINGS OFF      --->
               INSERT INTO [dbo].[di_audit_corp_upc_ldr_tbl]
                                  ( cpt_dpt_cd,cpt_com_cd,sub_com_cd,con_upc_no,pid_lng_dsc_tx,pid_sht_dsc_tx)
               VALUES
                        (<cfqueryparam value='#left(trim(listgetAt('#index#',2,',')),2)#' cfsqltype="cf_sql_char">,
                         <cfqueryparam value='#left(trim(listgetAt('#index#',3,',')),3)#' cfsqltype="cf_sql_char">,
                         <cfqueryparam value='#left(trim(listgetAt('#index#',4,',')),5)#' cfsqltype="cf_sql_char">,
                         <cfqueryparam value='#left(trim(listgetAt('#index#',1,',')),13)#' cfsqltype="cf_sql_varchar">,                  
                         <cfqueryparam value='#left(trim(listgetAt('#index#',5,',')),25)#' cfsqltype="cf_sql_varchar">,
                         <cfqueryparam value='#left(trim(listgetAt('#index#',6,',')),12)#' cfsqltype="cf_sql_varchar">)    
         </cfquery>
      </cfloop>

       

      Error:
      An error occurred while executing DTS package to import data.
      Invalid list index 6.
      In function ListGetAt(list, index [, delimiters]), the value of index, 6, is not a valid as the first argument (this list has 5 elements). Valid indexes are in the range 1 through the number of elements in the list.

       

      i am unable to solve this issue can any one will help me to solve this issue

       

      Thanks,

      Kiran