falcorassassin 0 Newbie Poster

Hi guys,

I'm trying to write data from an excel spreadsheet to an Access database. When i run my program a message appears saying that the correct number of records have been saved, however when i check my access database no records have been written to the database table. Any help or advice would be greatly appreicated. Thanks in advance.

The code for writing to database:

Public Class Form1

    Dim connection As OleDbConnection
    Dim Command As OleDbCommand

    Private Sub btnTestRecords_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTestRecords.Click

        'database code

        Dim strCommand As String
        Dim intRows As Integer
        Dim TCaseID As ArrayList = comp.GetTestCaseID()
        Dim TIteration As ArrayList = comp.GetTestIteration()
        Dim TstID As ArrayList = comp.GetTestID()
        Dim TRelease As ArrayList = comp.GetRelease()
        Dim TStatus As ArrayList = comp.GetTestStatus()
        Dim TDate As ArrayList = comp.GetTestDate()
        Dim TTester As ArrayList = comp.GetTester()
        Dim TComments As ArrayList = comp.GetComments()
        Dim TIssue As ArrayList = comp.GetIssueID()

        connection.Open()

        For i As Integer = 0 To TCaseID.Count - 1
            Dim tmp As String = TCaseID(i)
            Dim length As Integer = TComments(i).ToString().Length
            strCommand = "INSERT INTO Test_Result (TestCaseID, TestIteration, TestID, Release, Status, TestDate, Tester, Comments, Issue) VALUES ("
            strCommand &= "'" & TCaseID(i) & "', '" & TIteration(i) & "', '" & TstID(i) & "', '" & TRelease(i)
            strCommand &= "', '" & TStatus(i) & "', '" & TDate(i) & "', '" & TTester(i) & "', '" & TComments(i) & "', '" & TIssue(i) & "')"
            Command = New OleDbCommand(strCommand, connection)
            intRows += Command.ExecuteNonQuery
        Next

        MsgBox(intRows & " Test Data Successfully Updated!")
        Me.Validate()
        Me.Test_ResultBindingSource.EndEdit()
        Me.Test_ResultTableAdapter.Update(Me.TestManagementProjectDataSet.Test_Result)

        connection.Close()

    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        'This line of code loads data into the 'TestManagementProjectDataSet.Test_Result' table.

        Me.Test_ResultTableAdapter.Fill(Me.TestManagementProjectDataSet.Test_Result)
        connection = New OleDbConnection(Test_ResultTableAdapter.Connection.ConnectionString)

    End Sub

End Class