I am trying to save database after inserting the records into dataset from external file.... But when I insert records and then try to save it, it does not save...No error comes up though.??? Can you please look into the code and help??

        If file_path = Nothing Then
            Msgbox.Show ("Database file path is not provided!")
        End If
        Using reader As StreamReader = New StreamReader(file_path)
            ficontent = reader.ReadToEnd
        End Using

Dim lines As String() = ficontents.Split(":")
        Dim recs As New DataTable()
        Dim key As String = lines(0).Substring(0, lines(0).ToString.IndexOf("]") + 1)
        lines(0) = lines(0).Remove(0, lines(0).ToString.IndexOf("]") + 1)

        Try
            Dim m As Integer = 0
                    For i = 0 To lines.Count - 1 Step 8 '// Add books - 1st part
                        Dim s As String = lines(i).Trim()

                        Dim bool As Boolean = s.ToString.StartsWith("#")
                        If bool = True Then
                            m = i
                            Exit For
                        End If
                        Dim newbkRow As BooksDataSet.BooksRow
                        newbkRow = BooksDataSet1.Books.NewBooksRow
                        newbkRow.ID = lines(i).ToString
                        newbkRow.Name = lines(i + 1).ToString
                        newbkRow._Other_Name_s_ = lines(i + 2)
                        newbkRow.Author = lines(i + 3)
                        newbkRow.Publication_Details = lines(i + 4)
                        newbkRow.ISBN_Number = lines(i + 5)
                        newbkRow._Subjects_Tags = lines(i + 6)
                        newbkRow.Genre = lines(i + 7)
                        BooksDataSet1.Books.Rows.Add(newbkRow)
                        '// Save Database
                        Me.Validate()
                        Me.TableAdapterManager1.UpdateAll(BooksDataSet1)
                        Me.BooksTableAdapter1.Update(newbkRow)
                    Next


        Catch ex As Exception
            MsgBox(ex.Message)
        End Try

Hi
What database are you using?

You refer to BooksDataSet and BooksDataSet1 what are they? Data sets? should they be the same?

How are you retrieving your data? DataAdapter?

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.