Jump to content
xisto Community
Sign in to follow this  
falcorassassin

Help With Writing To Access Database With Vb.net

Recommended Posts

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[tab][/tab]	'database code[tab][/tab]	Dim strCommand As String[tab][/tab]	Dim intRows As Integer[tab][/tab]	Dim TCaseID As ArrayList = comp.GetTestCaseID()[tab][/tab]	Dim TIteration As ArrayList = comp.GetTestIteration()[tab][/tab]	Dim TstID As ArrayList = comp.GetTestID()[tab][/tab]	Dim TRelease As ArrayList = comp.GetRelease()[tab][/tab]	Dim TStatus As ArrayList = comp.GetTestStatus()[tab][/tab]	Dim TDate As ArrayList = comp.GetTestDate()[tab][/tab]	Dim TTester As ArrayList = comp.GetTester()[tab][/tab]	Dim TComments As ArrayList = comp.GetComments()[tab][/tab]	Dim TIssue As ArrayList = comp.GetIssueID()[tab][/tab]	connection.Open()[tab][/tab]	For i As Integer = 0 To TCaseID.Count - 1[tab][/tab][tab][/tab]	Dim tmp As String = TCaseID(i)[tab][/tab][tab][/tab]	Dim length As Integer = TComments(i).ToString().Length[tab][/tab][tab][/tab]	strCommand = "INSERT INTO Test_Result (TestCaseID, TestIteration, TestID, Release, Status, TestDate, Tester, Comments, Issue) VALUES ("[tab][/tab][tab][/tab]	strCommand &= "'" & TCaseID(i) & "', '" & TIteration(i) & "', '" & TstID(i) & "', '" & TRelease(i)[tab][/tab][tab][/tab]	strCommand &= "', '" & TStatus(i) & "', '" & TDate(i) & "', '" & TTester(i) & "', '" & TComments(i) & "', '" & TIssue(i) & "')"[tab][/tab][tab][/tab]	Command = New OleDbCommand(strCommand, connection)[tab][/tab][tab][/tab]	intRows += Command.ExecuteNonQuery[tab][/tab]	Next[tab][/tab]	MsgBox(intRows & " Test Data Successfully Updated!")[tab][/tab]	Me.Validate()[tab][/tab]	Me.Test_ResultBindingSource.EndEdit()[tab][/tab]	Me.Test_ResultTableAdapter.Update(Me.TestManagementProjectDataSet.Test_Result)[tab][/tab]	connection.Close()	End Sub	Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load[tab][/tab]	'This line of code loads data into the 'TestManagementProjectDataSet.Test_Result' table.[tab][/tab]	Me.Test_ResultTableAdapter.Fill(Me.TestManagementProjectDataSet.Test_Result)[tab][/tab]	connection = New OleDbConnection(Test_ResultTableAdapter.Connection.ConnectionString)	End SubEnd Class

Share this post


Link to post
Share on other sites
could not connect to a centralized DBHelp With Writing To Access Database With Vb.net

Please,

I am Francis Onodueze a student of IMSU

I have developed a Hotel Managment Software but for a considerable period of time, I have not been able to  access the DB from another computer; eventhough the software is runing perfectly as a standalone  software -  I need it  run on the network (centralized DB)

The platform: VB.Net

Connection String: DataSource=.SQLEXPRESS;AttachDbFilename=Infranet-e6ea07SharedDocsApp_DataDreamLandDB.Mdf;Integrated Security=True;User Insatnce=True

Error message: Infranet-e6ea07SharedDocsApp_DataDreamLandDB.Mdf failed. A database with the same name exist; or specified file cannot be opened, or it is located on UNC share

I cant forget this help if u rescue me from this trigger.

Your Programmer friend Francis

-question by Francis

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.