| | |
Writing to Access database using VB.net
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Apr 2009
Posts: 1
Reputation:
Solved Threads: 0
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:
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:
VB.NET Syntax (Toggle Plain Text)
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
![]() |
Similar Threads
- vb.net database connection (VB.NET)
- Inserting,deleting,updating and editing records to a MS Access database (C#)
- Database Connectivity (Visual Basic 4 / 5 / 6)
- Writing to an Access Database (Visual Basic 4 / 5 / 6)
- connecting to Access Db (ASP.NET)
- Problem with VB.NET and MS Access (VB.NET)
- Manipulating A Database (C#)
Other Threads in the VB.NET Forum
- Previous Thread: Update query not working in VB.NET
- Next Thread: picture uploading in VB
| Thread Tools | Search this Thread |
"crystal .net 2008 access add advanced application array assignment basic beginner box browser button buttons center click client code combo convert cpu cuesent data database datagrid datagridview datetimepicker designer dissertation dissertations dissertationtopic dosconsolevb.net eclipse editvb.net employees excel exists firewall forms html images isnumericfuntioncall listview map math memory mobile module msaccess mssqlbackend mysql navigate net number opacity open pan pdf picturebox picturebox2 port print printpreview record regex reuse right-to-left save search serial settings socket sorting sqldatbase sqlserver storedprocedure temp textbox timer transparency txttoxmlconverter upload useraccounts usercontol vb vb.net vb.nettoolboxvisualbasic2008sidebar vba vbnet vista visual visualbasic visualbasic.net visualstudio.net web winsock wpf wrapingcode xml





