Results 1 to 4 of 4

Thread: [RESOLVED] TableAdapter.Update does not save data!

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2013
    Posts
    124

    Resolved [RESOLVED] TableAdapter.Update does not save data!

    Hi, this is a very very weird problem. I have a mysql database with two tables. I have a BindingSource/TableAdapter for each, and several TextBoxs binding to each, all created with the designer.

    For the update I do this:

    Code:
    X_BindingSource.EndEdit()
    X_TableAdapter.Update(X_DataSet.Table)
    For the first table, when I edit a TextBox and then do the update, every thing works fine; the database is updated.
    But for the second one, the update does not go to the database on disk. The update functions returns 0 although the binding is correct and I don't call any AcceptChanges before the update.

    Now here's the weirdest thing; when I run the project from another machine and connect to the mysql server on the development machine the update works fine with the two tables. But when I work locally on the development machine and run the project, the problem arises, the update works only with the first table whether I connect to the local mysql server or to the mysql server on the production machine.

    This leads my to confirm that it's not my code because it works on other machines. And also it's not mysql server on the development machine since it works when I connect to it from other machines, so it's properly something wrong with my development machine.

    And here's the weirdest thing EVER, everything was working fine days ago, and I didn't change any code or make any changes to the development machine.

    Things I tried:
    1. Restore my machine to several restore points; problem persists.
    2. Repair all packages related to the development through Add/Remove Programs feature; mysql, Visual Studio, .NET Framework, .Net Connectors...etc; problem persists.

    Any ideas would be much much appreciated. Thank you.

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    107,639

    Re: TableAdapter.Update does not save data!

    If Update is returning zero then that means that there are either no changes in the DataTable or there are no matching records in the database. You need to check which it is immediately before the call. Set a breakpoint and, when it's hit, look at the data in the DataTable and in the database. Once you know what's wrong with the data, you can start to determine why.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jan 2013
    Posts
    124

    Re: TableAdapter.Update does not save data!

    Hello jmc & thank you for the kind reply
    Quote Originally Posted by jmcilhinney View Post
    You need to check which it is immediately before the call. Set a breakpoint and, when it's hit, look at the data in the DataTable and in the database.
    I've already done that, the matching record is in the DataTable and in the Database, the data is changed in the DataTable once I edit the textbox (because of the data binding of course), but after I do the update the database doesn't change. This strange behavior happens only on the development machine. In other machines the same update process runs smoothly as expected!

    It's likely to me that the TableAdapter fails for some reason in its job because I can update the same database using a mysql update query. The question is: Why does the same TableAdapter fail in the development machine but works on other machines? And why does it work with the first table but fail with the second one? The second table is huge, it has 125 fields and 30,000 records, while the first one has only 10 fields and 20 records. Is it because of that? I'm completely lost because it used to work in spite of that!

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jan 2013
    Posts
    124

    Re: TableAdapter.Update does not save data!

    UPDATE: I ended up with replacing the development machine with a new and more powerful one. And now everything is working fine. This problem will be a mystery to me. I didn't get rid of the machine in case I might figure it out in the future. I gave it to my 10 year old son for gaming. Now he's happy and I'm happy.

    End of story.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width