Visual Basic .NET Forums  
Click here to advertise with us

Go Back   Visual Basic .NET Forums > Database > MS Access

MS Access Related discussions using Access and JET as the backend

VB.NET Forums Newsletter Signup:
Email address:


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-06-2009, 12:20 PM
VB.NET Forum Newbie
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: May 2009
Posts: 22
Reputation: 12
thek is on a distinguished programming path ahead
Default Data not updated until restart

Hi.

When I add a new entry in a access database via the GUI, the vb.net program must be restartet before I can see the data in the GUI.

1. Why?
2. How to fix it?

Thanks

Code:
Dim cb As New OleDb.OleDbCommandBuilder(da)
            Dim dsNewRow As DataRow

            dsNewRow = ds.Tables("MyTabel").NewRow()

            dsNewRow.Item("Email") = txtEmail.Text
            dsNewRow.Item("Name") = txtName.Text

            ds.Tables("MyTabel").Rows.Add(dsNewRow)
            da.Update(ds, "MyTabel")
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 07-06-2009, 6:46 PM
cjard's Avatar
VB.NET Forum All-Mighty
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: Apr 2006
Age: 65
Posts: 6,442
Reputation: 807
cjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond repute
Default

Read the DW2 link in my signature, section Creating a Simple Data App
__________________
DW1 DW2 DW3 DW4 DNU PQ
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 07-07-2009, 1:24 AM
VB.NET Forum Newbie
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: May 2009
Posts: 22
Reputation: 12
thek is on a distinguished programming path ahead
Default

I have allready looked there, because when I searched the forum, you have reply others with the same reply.

But there are a lot of walkthroughs. Can you point me to the right one?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 07-07-2009, 9:57 AM
cjard's Avatar
VB.NET Forum All-Mighty
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: Apr 2006
Age: 65
Posts: 6,442
Reputation: 807
cjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond repute
Default

Quote:
Originally Posted by cjard View Post
Read the DW2 link in my signature, section Creating a Simple Data App
Creating a Simple Data App
__________________
DW1 DW2 DW3 DW4 DNU PQ
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 07-07-2009, 1:56 PM
VB.NET Forum Newbie
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: May 2009
Posts: 22
Reputation: 12
thek is on a distinguished programming path ahead
Default

No help in your links.

Maybe I didn't make myself clear, but I have made the vb.net application manualy, and not via the "drag'n drop" tools, becuase I need to show data in custom fields and controls.

The above code updates the database with new information and stores it, but the new data is not shown in my application. I have to close the application and open it again, before the new data is shown.

Somehow I need to "form_load" the entire application, without closing it or re-fresh the database via the application (I prefer the last option)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 07-08-2009, 2:34 AM
jmcilhinney's Avatar
VB.NET Forum Moderator
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Aug 2004
Location: Sydney, Australia
Age: 40
Posts: 6,126
Reputation: 542
jmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalist
Default

The data will be displayed in any controls that are bound to the DataTable you added the row to. If you're not seeing the data then I can only assume that you haven't bound that DataTable to any controls.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 07-08-2009, 6:22 AM
cjard's Avatar
VB.NET Forum All-Mighty
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: Apr 2006
Age: 65
Posts: 6,442
Reputation: 807
cjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond repute
Default

Quote:
Originally Posted by thek View Post
No help in your links.
If you'd done stuff as described in the links, then you wouldnt have any problem


Quote:
Maybe I didn't make myself clear, but I have made the vb.net application manualy, and not via the "drag'n drop" tools, becuase I need to show data in custom fields and controls.
Nothing stopping you doing that after following the links though..

Quote:
The above code updates the database with new information and stores it, but the new data is not shown in my application. I have to close the application and open it again, before the new data is shown.
As JMC points out, youre putting data into a datatable that isnt linked to the display (because you wanted to do it yourself because you have custom controls) and pushing to the database. Hence, theres a disconnect: the only time you show things on screen is when you download them from a database, the only time you download from a database is in form_load and youre now complaining that changes you made to the database that you didnt download are not being shown

Quote:
Somehow I need to "form_load" the entire application, without closing it or re-fresh the database via the application (I prefer the last option)
The preferred option is to have a local cache of data that you show, update and send back to the database; after all, you don't reopen a word document every time you save it
__________________
DW1 DW2 DW3 DW4 DNU PQ
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 07-08-2009, 7:31 AM
VB.NET Forum Newbie
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: May 2009
Posts: 22
Reputation: 12
thek is on a distinguished programming path ahead
Default

Yes, I'm aware that if I follow the step-by-step solution, then It's working correct, but the reason for my post is that it's not working when I created the code myself, and I need help

What I would like is the (I pretty sure it's simple) code for the dataset to update the database. Then Open() Close() to get the new database again, for display in the GUI.

The problem is if I add this:

Code:
Public Sub Database_load()
        dbProvier = "PROVIDER=Microsoft.Jet.OLEDB.4.0;"
        dbSource = "Data Source = C:\testDB.mdb"
        con.ConnectionString = dbProvier & dbSource
        con.Open()
        sql = "SELECT * FROM SpilDATA"
        da = New OleDb.OleDbDataAdapter(sql, con)
        da.Fill(ds, "SpilDATA")
        con.Close()
        End Sub
And then add this in Form_load

Code:
Database_load()
And then again in the bottom here:


Code:
       Dim cb As New OleDb.OleDbCommandBuilder(da)
                Dim dsNewRow As DataRow

                dsNewRow = ds.Tables("SpilDATA").NewRow()

                dsNewRow.Item("SPIL") = txtSPIL.Text
                dsNewRow.Item("CreatedBy") = txtCreatedBy.Text
                dsNewRow.Item("Assign") = txtAssign.Text
                dsNewRow.Item("Severity") = cboSeverity.Text


                ds.Tables("SpilDATA").Rows.Add(dsNewRow)
                da.Update(ds, "SpilDATA")
                Database_load()


Then the records are dobble, in the GUI.

Thanks.

Last edited by thek; 07-08-2009 at 7:43 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 07-08-2009, 7:42 AM
VB.NET Forum Newbie
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: May 2009
Posts: 22
Reputation: 12
thek is on a distinguished programming path ahead
Default

.....youre now complaining that....

I'm not complaning, I'm asking for help.

I've ready your link, I've read the database sections in VB 2005 and VB for dummies, and servel articles on the net, but no luck.

And what more confuses me, is that I have an EDIT and DEL button as well.

When editing a record via gui, then it’s updated – without a new load from the database
When deleting a record via gui, then it’s removed – without a new load from the database


That's why I'm asking here.

Last edited by thek; 07-08-2009 at 7:54 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 07-08-2009, 8:00 AM
jmcilhinney's Avatar
VB.NET Forum Moderator
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Aug 2004
Location: Sydney, Australia
Age: 40
Posts: 6,126
Reputation: 542
jmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalistjmcilhinney VB.NET gold medalist
Default

If you're loading the data in your Load event handler and you want to be able to load the data elsewhere too then just take the code out of the Load event handler and put it into a method that you can call from anywhere.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





All times are GMT -4. The time now is 6:26 AM.

Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2


For advertising opportunities click here.