Results 1 to 4 of 4

Thread: skipping line 2 when uploaded

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 2012
    Posts
    24

    skipping line 2 when uploaded

    hey having this problem and cant figure it out. This is my code:

    Code:
    Dim InstitutionFileReader As New System.IO.StreamReader("C:\Documents and Settings\CSchexnaydre\Desktop\TEST SHEETS\Institution\HD2010.csv")
                InstitutionFileReader.ReadLine()
    
                Dim i As Integer
    
                INSERT_INST_COMMAND = WFSDSTRING.CreateCommand()
    
                'Enable double quotes as string delimiters on the SQL Server
                INSERT_INST_COMMAND.CommandText = "SET QUOTED_IDENTIFIER OFF"
                INSERT_INST_COMMAND.ExecuteNonQuery()
    
                'Get rid of header line
                InstitutionFileReader.ReadLine()
    
                While Not InstitutionFileReader.EndOfStream
                    INSERT_INST_COMMAND.CommandText = "INSERT INTO Institution_UPLOAD (Institution_ID, Institution_Name, Address_1, City, State_Code, Zip, FIPS, OBE_Region_ID, Chief_Admin_Name_ID, Chief_Admin_Title_ID, Institution_Phone, ENI, OPE_Number, OPEFLAG_ID, Institution_Web, Admission_Web, Financial_Web, Application_Web, SECTOR, Type_Of_Institution_ID, Level_Of_Institution_ID, HLOFFER_ID, UGOFFER_ID, GROFFER_ID, HDEGOFR1_ID, DEGGRANT_ID, Historic_Black_College_ID, Hospital_Available_ID, Medical_Degree_ID, Tribal_College_ID, Location_ID, Open_To_Public, ACT_ID, New_ID, Deleted_Year, Closed_Date, CYACTIVE_ID, POSTEC_ID, PSEFLAG_ID, PSET4FLG_ID, RPTMTH_ID, ALIAS, INSTCAT_ID, CCBASIC_ID, CCIPUG_ID, CCIPGRAD_ID, CCUGPROF_ID, CCENPRF_ID, CCSIZSET_ID, CARNEGIE_ID, TENURSYS_ID, Land_Grant_Institution_ID, Size_Of_Institution_ID, CBSA_ID, CBSATYPE_ID, CSA_ID, NECTA_ID, F1SYSTYP_ID, F1SYSNAM, Institution_Fax) " & _
                        "VALUES (" & InstitutionFileReader.ReadLine() & ")"
                    i = INSERT_INST_COMMAND.ExecuteNonQuery()
                End While
    
                InstitutionFileReader.Close()
                InstitutionFileReader = Nothing
    
            End If
    it works fine but the only problem i am having with it is that its skipping line 2 which includes a row of data that needs to be uploaded to the database.

    Example of .csv file:

    Column1, Column2, Column3
    Value1, Value2, Value3 <<<<<<<< Skipping this one
    Value1, Value2, Value3
    Value1, Value2, Value3
    Value1, Value2, Value3

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,413

    Re: skipping line 2 when uploaded

    vb Code:
    1. Dim InstitutionFileReader As New System.IO.StreamReader("C:\Documents and Settings\CSchexnaydre\Desktop\TEST SHEETS\Institution\HD2010.csv")
    2.             InstitutionFileReader.ReadLine() 'doesn't this get rid of header line?

  3. #3
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: skipping line 2 when uploaded

    VB Code:
    1. Dim InstitutionFileReader As New System.IO.StreamReader("C:\Documents and Settings\CSchexnaydre\Desktop\TEST SHEETS\Institution\HD2010.csv")
    2.             InstitutionFileReader.ReadLine() 'Reads header line
    3.  
    4.             Dim i As Integer
    5.  
    6.             INSERT_INST_COMMAND = WFSDSTRING.CreateCommand()
    7.  
    8.            
    9.             INSERT_INST_COMMAND.CommandText = "SET QUOTED_IDENTIFIER OFF"
    10.             INSERT_INST_COMMAND.ExecuteNonQuery()
    11.  
    12.            
    13.             InstitutionFileReader.ReadLine() 'reads first line of data
    14.  
    15.             While Not InstitutionFileReader.EndOfStream
    16.                 INSERT_INST_COMMAND.CommandText = "INSERT INTO Institution_UPLOAD (Institution_ID, Institution_Name, Address_1, City, State_Code, Zip, FIPS, OBE_Region_ID, Chief_Admin_Name_ID, Chief_Admin_Title_ID, Institution_Phone, ENI, OPE_Number, OPEFLAG_ID, Institution_Web, Admission_Web, Financial_Web, Application_Web, SECTOR, Type_Of_Institution_ID, Level_Of_Institution_ID, HLOFFER_ID, UGOFFER_ID, GROFFER_ID, HDEGOFR1_ID, DEGGRANT_ID, Historic_Black_College_ID, Hospital_Available_ID, Medical_Degree_ID, Tribal_College_ID, Location_ID, Open_To_Public, ACT_ID, New_ID, Deleted_Year, Closed_Date, CYACTIVE_ID, POSTEC_ID, PSEFLAG_ID, PSET4FLG_ID, RPTMTH_ID, ALIAS, INSTCAT_ID, CCBASIC_ID, CCIPUG_ID, CCIPGRAD_ID, CCUGPROF_ID, CCENPRF_ID, CCSIZSET_ID, CARNEGIE_ID, TENURSYS_ID, Land_Grant_Institution_ID, Size_Of_Institution_ID, CBSA_ID, CBSATYPE_ID, CSA_ID, NECTA_ID, F1SYSTYP_ID, F1SYSNAM, Institution_Fax) " & _
    17.                     "VALUES (" & InstitutionFileReader.ReadLine() & ")" 'reads 2nd & subsequent lines of data
    18.                 i = INSERT_INST_COMMAND.ExecuteNonQuery()
    19.             End While
    20.  
    21.             InstitutionFileReader.Close()
    22.             InstitutionFileReader = Nothing
    23.  
    24.         End If

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Jun 2012
    Posts
    24

    Re: skipping line 2 when uploaded

    Quote Originally Posted by .paul. View Post
    vb Code:
    1. Dim InstitutionFileReader As New System.IO.StreamReader("C:\Documents and Settings\CSchexnaydre\Desktop\TEST SHEETS\Institution\HD2010.csv")
    2.             InstitutionFileReader.ReadLine() 'doesn't this get rid of header line?
    dang thankz .paul. for the second time today lmao u right i had it twice lol

    thankz again

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width