none
Update Successful till I shut down RRS feed

  • Question

  • I have a successful update method for my table adapter. But it only seems to successfully update my data grid. If I keep the program running then go to the table and view it in MSaccess my table is updated the way I want but when I shut down my vb program and bring it back up none of my changes exist anymore. Seems I am updating my table adapter only temporarily.
    Tuesday, January 11, 2011 4:57 PM

Answers

  • Thanks this was the solution to my update issue. What I did was set it to Do Not Copy then I just got a copy of the original and put it in my debug floder manually copying it that first time.

    I still don't know why the wizard didn't create an update command for me but I wrote that manually as well.

    Friday, January 14, 2011 4:49 PM

All replies

  • Hello DaveBootsma,

     

    Welcome to the MSDN Forum and thank you for posting here.

    Based on your description, I don't have a repro for your exact scenario, but the VS.NET Program Manager's explaination may help you.

    Below is David Sceppa's reply:

     "If you connect to a SQL Server database file in Visual Studio.NET 2005 Server Explorer and then create your Data Source using that connection, VS.NET will display a dialog asking the following question:

    "The connection you selected uses a local data file that is not in the current project. Would you like to add the file to your project and modify the connection?"

    If you say "Yes", when you build the application VS.NET will copy the .mdf file into the application's output directory, where the executable file lives.  The design-time connection in Server Explorer will still point to the original .mdf file rather than the copy in your output directory.  This approach simplifies the process of packaging and deploying your application.  However, the approach has some interesting side effects.

    You can then run your code and successfully add/modify/delete rows in your code to change the contents of the .mdf file that resides in the output directory.  However, if you check the contents of the .mdf file through Server Explorer, you won't see the new data because you're looking at the original .mdf file. 

    There's another side effect of examining the .mdf file through Server Explorer.  The next time you build the application, VS.NET will copy the original .mdf file into the output directory again.  If you look at the .mdf file in Solution Explorer, you'll see that it's marked as "Copy if newer".  VS.NET checks timestamps in the original .mdf file to determine when to perform the copy.  This way, if you modify rows or schema in the original .mdf file, those changes will be available in the .mdf file in the output directory.  According to the VS.NET team, the .mdf file is marked as "Copy always" in Solution Explorer in post-Beta 2 builds.

    Say that your application creates a new row and submits it to your .mdf file using a TableAdapter, a DataAdapter, an INSERT INTO query or a stored procedure call.  You can execute that code, see that the return value indicates success, and even query the table to verify that the new row exists.  If you check the contents of the .mdf file in Server Explorer, you won't see the new row.  You'll also cause VS.NET to re-copy the .mdf file into the application's output directory, and the changes you made the last time you ran the application will be gone."

    And here is the link:

    http://social.msdn.microsoft.com/forums/en-US/adodotnetdataproviders/thread/4db25120-99e1-41b6-a784-a4484af31a3f/

    I know your database is MSAccess, but maybe it has the same problem with MSSQL. So why not have a try.

     

    I hope it can help you.

    Please feel free to let us know if I have misunderstood you.

     

    Have a nice day,

     


    Jackie Sun [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, January 13, 2011 5:44 AM
    Moderator
  • Can you show how you update the actual table using TableAdapter?
    Val Mazur (MVP)

    http://www.xporttools.net

    Friday, January 14, 2011 11:57 AM
    Moderator
  • Thanks this was the solution to my update issue. What I did was set it to Do Not Copy then I just got a copy of the original and put it in my debug floder manually copying it that first time.

    I still don't know why the wizard didn't create an update command for me but I wrote that manually as well.

    Friday, January 14, 2011 4:49 PM