I've tried various things to get the datagrids to update. If I close the application and reload it then I see the changes to the database. If I do a transactions I don't see them until I reload it. This is where I currently left off.

bank_Account_DatabaseDataSet.GetChanges();
            bank_Account_DatabaseDataSet.Savings.AcceptChanges();
            this.savingsTableAdapter.Fill(this.bank_Account_DatabaseDataSet.Savings);
            savDtGrdVw.Refresh();
            savDtGrdVw.Update();

just on the savings because until I can get it to work for one grid, no sense of playing with the other. I also tried to run my closeDatabase and getDatabase() methods. That didn't work. I've included the whole application and the database in the zip.

Recommended Answers

All 13 Replies

Are you using M V C#2008 Express?

Yes I'm using Microsoft Visual C# Express 2008.

Well the database in your project is not always the same! There is a copy of it in a bin folder I believe. I don't know exactly how it was, but I will look it up and let you know something as soon as possible.

There is something wrong with your zip btw.
But.
I have a possible solution to your problem.(I think... Don't shoot me if it's not.)
The version of the database you see in solution explorer is not the same version of the database that is used by your application.
Instead the db of sol ex is copied to the output directory, where .exe file lives for example in .../bin/debug every time you run your app.
Set the property of your db called Copy to output directory to Copy If Newer and it should be ok.(I hope)

That didn't work. It doesn't matter if I point it to the root mdb, the one in Release or Debug. It will update the database in any of the three locations. I can open it in access and see the updates. But my grid view is only showing me what is loaded at run time.

Still figuring out your code.
Is all your editing done between BeginEdit and EndEdit?

Not sure I follow the question?

A DataGridView has BeginEdit, EndEdit and CommitEdit methods. Check these out on MSDN.

I looked a little at the BeginEdit (still going to read a little more), but I would say no I'm doing any editing with the DataGrid so I'm not using BeginEdit, EndEdit and CommitEdit methods. I'm using statements like

DBcmd.CommandText = "INSERT INTO Savings VALUES('" + System.DateTime.Now.ToString() + "','" + transaction + "','" + amountTxtBx.Text + "','" + retrieveBalance + "')";
            try
            {
                int row_affected = DBcmd.ExecuteNonQuery();
            }

To inject the changes directly into the database. I also was thinking I could get tricky last night. Figuring when I close the application and open it up the DataGrid loads the database fine. So I tried to create a second form form, putting a DataGrid on it. That way I can load and close it, maybe it would do the same thing as closing and opening the main form, and nope it doesn't. I did a copy and paste of the existing DataSet and adapters. So today I'm going to create it new out of the box.

The problem is not fixed in this version either. No real reason to submit it other than it is prettier and easier to look at. I put the gridviews on a new form and it makes Form1 less cluttered in design view. I really was hoping that because when I close Form1 and reopen it, the gridviews update, that by putting them on a Form2 that opens and close I could duplicate that. It still only shows what is available when Form1 loads?

I cannot find a checkingTableAdapter.Update method in your code I believe this is needed but I'm not 100% shure.

I've tried to use that in my savTransaction and chckTransaction methods to no avail. I tried setting it to close Form1 and open a new one, but as I've learned (and web verified it is by design) when you close Form1 the application exits. I know the database is updating and not sure if it is tied to your earlier post of there being copies in bin/Release and bin/Debug. All I know is I'm not getting any kind of refresh here. I wonder if on run time if it isn't loading the database into memory and what I see is only what it there? My transaction methods write directly to the database on the HD, not anything in memory. I'll try to throw in some updates and refreshing into the Form2. I'll do a little over kill and try to do the DataSet, TableAdapters, and BindingSources.

PS. I have a homework assignment due by Tuesday and final project due by next Sunday. I will have to shelve this a little so my replies might take days or even a week to get back to anyone.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.