I have a problem with retrieving data from access databse.
I make the connection and retrieve the data no problem. But when the data changes from another use of the database, I cannot get the new changed data without reloading the complete programme. Even repeating the load functions does not renew the data from the access data base.
Here is what I have got:
Public Class Form1
Private comm As New CommManager()
Private transType As String = String.Empty
Dim inc As Integer
Dim con As New OleDb.OleDbConnection
Dim dbProvider As String
Dim dbSource As String
Dim laptimes As New DataSet
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
dbProvider = "PROVIDER=Microsoft.Jet.OLEDB.4.0;"
dbSource = "Data Source = f:/HareHound riderinput local.mdb;"
con.ConnectionString = dbProvider & dbSource
sql = "SELECT * FROM laptimes"
da = New OleDb.OleDbDataAdapter(sql, con)
Private Sub btnimportdata_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnimportdata.Click
CheckBox1.Checked = laptimes.Tables("HareHounds").Rows(0).Item(10)
I have tried everthing to get this very simple thing to work, but I am at a loss. Help would be largly apreciated.
2 Months Ago
Related Article:database connectivity in vb.net
is a VB.NET discussion thread by sheelap that has 2 replies, was last updated 1 year ago and has been tagged with the keywords: problem, with, database, connectivity, in, vb.net.
Move that code out of the form_load event into its own function. You can call that function from form_load to get the data at startup but you will also be able to call the code at anytime to get any new data (via a button that calls that function for example)
I solved this my self in the end. What you have to do is make a seperate function that contains a OleDb.OleDbCommandBuilder and an update comanad.
This then updates the real database and not the one loaded into memnory. Seems like an od way to do things but it works.