Ok, I'm not sure how to format the readline to skip the header columns of the file that is being read in the code that I wrote/spliced in my class. I was wondering if anyone can point me in the right direction here.

Thanks in advance!

Private Sub btnLoadFromText_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLoadFromText.Click
        ' setup Variables
        Dim myRecord As String    ' for each line (record) from the CSV file
        Dim aryFields() As String ' array to contain fields
        Dim strID As String       ' for the station ID
        Dim strSQL As String      ' for the SQL command

        ' Open the CSV File
        Dim myFile As New StreamReader(_strFilePath)

        ' establish a connection to the DB and open it
        _dbConn.ConnectionString = _strConn
        _dbConn.Open()
        _dbCmd.Connection = _dbConn

        ' continue processing until I hit the end of CSV file
        Do Until myFile.EndOfStream

            ' read a record and split into fields
            myRecord = myFile.ReadLine

            aryFields = Split(myRecord, ",")

            ' Determine the value of the key field
            strID = aryFields(0)

            ' add a blank record into the database with a key field
            strSQL = "INSERT INTO stations (stationID) VALUES ('" & strID & "')"
            _dbCmd.CommandText = strSQL
            _dbCmd.ExecuteNonQuery()

            ' update the StationName
            strSQL = "UPDATE stations SET stationName='" & aryFields(1) & "' WHERE stationID='" & strID & "'"
            _dbCmd.CommandText = strSQL
            _dbCmd.ExecuteNonQuery()

            ' update the State
            strSQL = "UPDATE stations SET state='" & aryFields(2) & "' WHERE stationID='" & strID & "'"
            _dbCmd.CommandText = strSQL
            _dbCmd.ExecuteNonQuery()

        Loop

        ' Close the database
        _dbConn.Close()
    End Sub

adding this statement,myRecord = myFile.ReadLine, before the Do loop should do the trick.

Thanks! Did the trick

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.