| Sr.No | Membership No | Name | Addresss | Occupation |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Account |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| | 35957 | SHAH HEMANGINI KANAIYALAL NATVARLAL |SHROFF STREET,, KILLA PARDI, DIST.VALSAD, Pardi, Pin Cd : 396125 |
| 1 | 35959 | SARSIWALA SAKINABEN ASGARALI ABDULHUSEIN |OPP.HIGHPOWER SODA FACTORY,, DUNGRI FALIA,DAMNI ZAPA,, KILLA PARDI.DIST.VAL |
| 2 | 36022 | PATEL BHARTIBEN BABUBHAI KHANDUBHAI |B/H BALMANDIR,, KANSARWAD,, KILLA PARDI., Pardi, Pin Cd : 396125 |
| 3 | 36023 | PATEL ASHISHKUMAR BABUBHAI KHANDUBHAI |B/H BALMANDIR,, KANSARWAD,, KILLA PARDI., Pardi, Pin Cd : 396125 |
| 4 | 36025 | SHAIKH HALIMABIBI UMARBHAI MOHMEDBHAI |OPP.JALARAM KHAMAN HOUSE,, CHIVAL ROAD,, KILLA PARDI.DIST.VALSAD, Pardi, Pi |
| 5 | 36072 | LAD PUSHPABEN VINODBHAI BHANABHAI |KUMBHARWAD,, VALSADI ZAPA,, KILLA PARDI,DIST.VALSAD, Pardi, Pin Cd : 396125 |
| 7 | 36076 | KOTHARI PANNABEN JANAKBHAI ISHVARLAL |VANIAWAD,, KILLA PARDI, DIST.VALSAD, Pardi, Pin Cd : 396125 |
| 8 | 36080 | PATEL DHARMESH BHAGUBHAI KANJIBHAI |NEAR RATAN RICE MILL,, DAMNI ZAPA,, KILLA PARDI., Pardi, Pin Cd : 396125 |
| 9 | 36081 | MAPARA BANKIMKUMAR SUNDARLAL HARJIVANDAS |BALAKHADI,, STATION ROAD,, KILLA PARDI, Pardi, Pin Cd : 396125 |
| 10 | 36084 | LAD JAMNABEN DAHYABHAI BHAGWANJI |KUMBHARWAD,, VALSADI ZAPA,, KILLA PARDI, Pardi, Pin Cd : 396125 |
| 11 | 36085 | PRAJAPATI RAKESHKUMAR THAKORBHAI KESHAVB |B/H NUTAN NAGAR,, KAKABAVANI WADI,, KILLA PARDI., Pardi, Pin Cd : 396125 |
| 12 | 36086 | PATEL BHANUBEN THAKORBHAI RAGHABHAI |B/H MOHAN DAYAL HOSPITAL,, DAMNI ZAPA,, KILLA PARDI., Pardi, Pin Cd : 39612 |
| 13 | 36089 | PATEL PRAFULBHAI BUDHABHAI CHHANABHAI |DANTI FALIA,, CHIVAL ROAD,, KILLA PARDI, Pardi, Pin Cd : 396125 |
| 14 | 36093 | JOSHI KANAKBHAI MANUBHAI |ISHVARPARK,, BRAHMIN FALIA,, KILLA PARDI, Pardi, Pin Cd : 396125 |
| 15 | 36095 | DESAI MEGHABEN BHAVINBHAI ISHVARBHAI |101-ANAND APARTMENT,, OPP.D.C.O.SCHOOL,BALAKHADI,, KILLA PARDI., Pardi, Pin |

For this text file I want to store SRNO,MembershipNo,Name,Address values in database.How to pick all these values individually and insert in database?
Help me with this.

Private Sub LoadCommaDelimetedTextFileIntoListBox(ByVal filePath As String)

        ' Declare a variable named theTextFieldParser of type TextFieldParser.
        Dim theTextFieldParser As FileIO.TextFieldParser

        ' Call the My feature's OpenTextFieldParser method passing in a file path.
        ' Assign the resulting TxtFileParser object to theTextFieldParser variable.
        theTextFieldParser = My.Computer.FileSystem.OpenTextFieldParser(filePath)

        ' Set TextFieldParser object's TextFieldType property to Delimited.
        theTextFieldParser.TextFieldType = Microsoft.VisualBasic.FileIO.FieldType.Delimited

        ' Configure delimiters to handle a comma delimited text file:
        ' Set TextFieldParser object's Delimiter's property to a string array
        ' containing one element with the value ",".
        theTextFieldParser.Delimiters = New String() {"|"}

        ' Declare a variable named currentRow of type string array.
        Dim currentRow() As String

        ' While the end of file has not been reached....
        While Not theTextFieldParser.EndOfData
            Try
                ' Read the fields on the current line
                ' and assign them to the currentRow array variable.
                currentRow = theTextFieldParser.ReadFields()

                ' Declare a variable named currentField of type String.
                Dim currentField As String

                ' Use the currentField variable to loop
                ' through fields in the currentRow.
                For Each currentField In currentRow
                    ' Add the the currentField (a string)
                    ' to the demoLstBox items.
                    Me.ListBox2.Items.Add(currentField)
                Next
            Catch malFormLineEx As Microsoft.VisualBasic.FileIO.MalformedLineException
                MessageBox.Show("Line " & malFormLineEx.Message & "is not valid and will be skipped.", "Malformed Line Exception")
            Catch ex As Exception
                MessageBox.Show(ex.Message & " exception has occurred.", "Exception")
            Finally
                ' Do any clean up if needed
            End Try
        End While


    End Sub

I am adding the red lines to listbox. In currecnt row currentRow = theTextFieldParser.ReadFields() you will get the data in array so you need to write a method which inserts the records in db by reading this array.

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.