Results 1 to 5 of 5

Thread: Help with Loop and Insert into Database (Resolved)

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2005
    Posts
    259

    Help with Loop and Insert into Database (Resolved)

    I am trying to insert a record into a database from each line in my text file. So far all I have accomplished is to insert 1 record (the same record) for each line in the file. So if I had 10 lines of different people I am getting some thing like this (see below) instead of the 10 different people.

    Fast Eddie
    Fast Eddie
    Fast Eddie
    Fast Eddie
    Fast Eddie
    Fast Eddie
    Fast Eddie
    Fast Eddie
    Fast Eddie
    Fast Eddie

    The code I have is
    Code:
    '***Subs
        Private Sub ReadFile()
    
            Dim oRead As StreamReader = _
                File.OpenText("C:\member.txt")
    
            Do While oRead.Peek >= 0
                Dim myLine As String = (oRead.ReadLine)
                Dim sAgent As String = myLine.Substring(0, 12)
                Dim sOffice As String = myLine.Substring(12, 12)
                Dim sName As String = myLine.Substring(24, 34)
                Dim sLName As String = myLine.Substring(58, 17)
                Dim sPhone As String = myLine.Substring(195, 12)
                Dim sExt As String = myLine.Substring(207, 4)
                Dim sFax As String = myLine.Substring(211, 12)
                Dim sEmail As String = myLine.Substring(207, 80)
                Dim sWeb As String = myLine.Substring(303, 80)
                Dim sDesig As String = myLine.Substring(386, 30)
                Dim sType As String = myLine.Substring(386, 30)
                Dim sLid As String = myLine.Substring(0, 12)
    
                InsertMember(sAgent, sOffice, sName, sLName, _
                    sPhone, sExt, sFax, sEmail, sWeb, sDesig, _
                    sType, sLid)
            Loop
            oRead.Close()
        End Sub
    Last edited by FastEddie; Apr 26th, 2008 at 01:21 PM.

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