We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,886 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

get new records from access database

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

        con.Open()
        sql = "SELECT * FROM laptimes"

        da = New OleDb.OleDbDataAdapter(sql, con)
        da.Fill(laptimes, "HareHounds")

        con.Close()

    End Sub
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)
    End Sub

I have tried everthing to get this very simple thing to work, but I am at a loss. Help would be largly apreciated.

2
Contributors
4
Replies
7 Months
Discussion Span
2 Months Ago
Last Updated
10
Views
Question
Answered
UKnod
Light Poster
35 posts since Jun 2009
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

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)

hericles
Veteran Poster
1,065 posts since Nov 2007
Reputation Points: 156
Solved Threads: 228
Skill Endorsements: 9

Yes I tried that, but it does not make any difference.
Odly enough I have writed another console based programe with pretty much the sanme code, and that does work.
What is the difference?

UKnod
Light Poster
35 posts since Jun 2009
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

sorry but backups has nothing to do with this subject?

UKnod
Light Poster
35 posts since Jun 2009
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

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.

UKnod
Light Poster
35 posts since Jun 2009
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
Question Answered as of 2 Months Ago by hericles

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0694 seconds using 2.68MB