Updating data table in VS 2005 express edition

I wonder how you have succeeded to make the datagrid update your database table. It doesn’t work for me – (I’m very close to opening my window and jumping through it).

It is easy to show data from access database but to update it is a real problem for me.

I used a wizzard to connect to the access db - it reported that it made select,insert,update and testing of connection was o.k.. New dataset is also visible in Datasource window. I used datagridview control an linked it with a table kraji from data set ProbaKrajiDataSet. So now I have a nice datagrid on form and it shows all present data in a DB table Kraji. Everything is o.k. until I change the data on a grid. I found out that next code......

Private Sub KrajiBindingSource_CurrentChanged(ByVal sender As Object, ByVal e as System.EventArgs) Handles KrajiBindingSource.CurrentChanged

Me.KrajiTableAdapter.Update(Me.ProbaKrajiNorthwindDataSet.Kraji)

End Sub

......only updates data in a grid so if you close down a grid and reopens it - it shows updated data. But if you close your build and reopens it it again shows the old data from table Kraji.

So the data in table Kraji (database) wasn't updated at all. Help!!!!!

Is this a Visual studio 2005 express issue or am I missing some code I'm searching for solution for some time now on forums, provided help in vs05express etc.

Can't find there would be anything wrong with the code.

Please if there is someone with an answer to this one.

Thanks in advance.

Klemen





Answer this question

Updating data table in VS 2005 express edition

  • AMH

    Hi,

    I'm glad it works for you.

    Are you hosting the combo boxes inside the data grid columns or the combo boxes are out in the form

    By the way, for Windows Forms questions, the experts in Windows Forms forums can always give faster and better answers.

    Best regards,



  • Wim_M

    Yes, fortunately I already got the same suggestion from Jay Hickerson. "It works"

    Now I work on combo box properties...

    To be exact...

    I'd like to lock combo1 to column1 of certain datagrid and combo2 to column 2 etc.

    I already found out how to extend the width of combo if the width of column extends.

    Now I'm working on locking position of combo to position of column so whenever the left border of column is moved combo's left border is also moved with it.

    Any suggestions on this one It should look nice on the form.

    Thanks for the answer. I appreciate it.

    Klemen



  • Max Andrade

    Hi,

    This may be a problem with using local data base in your project. When you reopen your program the local data base in your bin directory is replaced with the original one in your project. Please see http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=138462&SiteID=1 for more information but here's the solution:

    1. If you select local database file in the Solution Explorer window, you will see a property called ‘Copy to Output’ in the Properties window. By default it is set to ‘Copy Always’ which means that on each build, the data files in the project folder will be copied to the output folder overwriting the existing data files if any. You can set this property to Copy Never and then manually put a copy of the data file in the output folder. This way, on subsequent builds, the project system will leave the datafile in the output folder and not try to overwrite it with the one from the project. The downside is that you still have two copies so after you modify the database file using the app, if you want to work on those changes in the project, you need to copy it to the project manually and vise-versa.

    2. You can leave the data file outside the project and create a connection to it in Database Explorer. When the IDE asks you to bring the file into the project, just say no. This way, both the design-time and the run-time will be using the same data file but the downside is that the path in the connection string will be hard coded and therefore it’ll be harder to share the project and deploy the app. Before deploying the app, just make sure to replace the full path in the settings with a relative path.

    Hope this helps,



  • Agent00

  • Updating data table in VS 2005 express edition