Writing to Access database using VB.net

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Apr 2009
Posts: 1
Reputation: falcorassassin is an unknown quantity at this point 
Solved Threads: 0
falcorassassin falcorassassin is offline Offline
Newbie Poster

Writing to Access database using VB.net

 
0
  #1
Apr 6th, 2009
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:

  1. Public Class Form1
  2.  
  3. Dim connection As OleDbConnection
  4. Dim Command As OleDbCommand
  5.  
  6. Private Sub btnTestRecords_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTestRecords.Click
  7.  
  8. 'database code
  9.  
  10. Dim strCommand As String
  11. Dim intRows As Integer
  12. Dim TCaseID As ArrayList = comp.GetTestCaseID()
  13. Dim TIteration As ArrayList = comp.GetTestIteration()
  14. Dim TstID As ArrayList = comp.GetTestID()
  15. Dim TRelease As ArrayList = comp.GetRelease()
  16. Dim TStatus As ArrayList = comp.GetTestStatus()
  17. Dim TDate As ArrayList = comp.GetTestDate()
  18. Dim TTester As ArrayList = comp.GetTester()
  19. Dim TComments As ArrayList = comp.GetComments()
  20. Dim TIssue As ArrayList = comp.GetIssueID()
  21.  
  22. connection.Open()
  23.  
  24. For i As Integer = 0 To TCaseID.Count - 1
  25. Dim tmp As String = TCaseID(i)
  26. Dim length As Integer = TComments(i).ToString().Length
  27. strCommand = "INSERT INTO Test_Result (TestCaseID, TestIteration, TestID, Release, Status, TestDate, Tester, Comments, Issue) VALUES ("
  28. strCommand &= "'" & TCaseID(i) & "', '" & TIteration(i) & "', '" & TstID(i) & "', '" & TRelease(i)
  29. strCommand &= "', '" & TStatus(i) & "', '" & TDate(i) & "', '" & TTester(i) & "', '" & TComments(i) & "', '" & TIssue(i) & "')"
  30. Command = New OleDbCommand(strCommand, connection)
  31. intRows += Command.ExecuteNonQuery
  32. Next
  33.  
  34. MsgBox(intRows & " Test Data Successfully Updated!")
  35. Me.Validate()
  36. Me.Test_ResultBindingSource.EndEdit()
  37. Me.Test_ResultTableAdapter.Update(Me.TestManagementProjectDataSet.Test_Result)
  38.  
  39. connection.Close()
  40.  
  41. End Sub
  42.  
  43. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  44.  
  45. 'This line of code loads data into the 'TestManagementProjectDataSet.Test_Result' table.
  46.  
  47. Me.Test_ResultTableAdapter.Fill(Me.TestManagementProjectDataSet.Test_Result)
  48. connection = New OleDbConnection(Test_ResultTableAdapter.Connection.ConnectionString)
  49.  
  50. End Sub
  51.  
  52. End Class
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC