sample project "addresses" database

I just downloaded VB Express.   I am a beginner.  In the VBGuided Tour - managing your records, I tried the sample program "addresses" and the 3 addresses came up fine but I couldn't add any addresses to it.  I first hit the add button and blank text boxes came up, then I filled them in and hit the save button but nothing was saved.(that is when I closed the program and then ran it again just the original 3 addresses were there)  I read a few posts about this but now am more confused.  Can VB Express save data or not   If it can what code should be added to the sample project "addresses" so that it does work  

Allen


Answer this question

sample project "addresses" database

  • BennyAndGisela

    Thank you.  I found it and it now works. 

    One thing though.  I got to the firstDatabase.mdf properties (I was in the address project) by right clicking the firstDatabase.mdfnode and selecting properties. The property sheet that came up was..... firstDatabase.mdf File Properties          The listed properties were Build Action, Copy to Output Directory(where I made the change) custom tool, custom tool name, and a couple more. 

    However when I double clicked the same node firstDatabase.mdf firstDatabase.mdf (no File Properties so I guess this is something different )  came up and the properties that came up on the property sheet were Case Sensitive, connection string, owner primary file, etc which are completely different.  I found this confusing as I double clicked first and it took some time to spot the difference ie "File Properties" in the properties text box. 

    Can you guide me where to read up on what is going on here

    Thanks
    Allen

  • dhtroy

    Hi Allen,

    I can see how this could be confusing. I don't know of any documentation that explicitly covers this behavior, but let me try and explain.

    The contents of the Properties window constantly changes dependeing on what is currently selected in the IDE. When you select the firstDatabase.mdf node in Solution Explorer, the Properties window displays properties for the database file - these are properties that tell the IDE what to do with the file when it builds the project. Note that you don't need to right-click and choose Properties - the properties are automatically displayed when you select the node.

    When you double-click the firstDatabase.mdf file, you wll notice that the Database Explorer window opens (if it isn't already open) and the firstDatabse.mdf node in that window is highlighted. The contents of the Properties window now displays different properties related to the database - these are properties that tell SQL Server about the database file, and they are read-only (they can't be changed in the IDE, only from within SQL Server).

    Likewise, if you switch to the Forms designer, the Properties window will display properties related to the form, and if you select a control it will display the properties for that control.

    Hope this helps,
    Steve Hoag

  • Jeffrey.Ye

    First of All I would like to thank you all for helping me.

    Ok, I set the CopyToOutputDirectory to Copy If Newer. When I pressed the play button I am able to add, remove, edit the contents of the db using the Form1 app that runs. Ok, I changed one name from Dave to Bob, pressed the save button and closed the Form1. I go and check the db in the IDE and I notice none of the  changes I made were changed. Why is this

    I did notice that if I published the App and ran it, the changes to the DB ( must be in a different place once its published, just a guess) are there. I am new to VB and its a little confusing why this happens.

  • Christian Denny Petersen

    Magic Hat,

    There are actually two copies of the database, one in the project directory and one in the output directory. When you look at the database in the IDE you are looking at the project copy; when you run the app (either F5 or after publishing) you are looking at the output copy.

    The following thread explains this:
    http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=140988&SiteID=1

    Hope this helps,
    Steve

  • SupurbSoftEng

    I had a similar problem. I tried your fix.
    When I stop execution and check the database or run the app again, the changes weren't made.

    Can someone help me
    Did I not setup something right

  • colombod

    Hi Allen,

    This is a known problem with the Guided Tour due to a behavior change after the documentation was completed.

    To work around this:

    1.      In Solution Explorer, select the FirstDatabase.mdf node.

    2.      In the Properties window, select the Copy to Output Directory property and change the value to Copy if newer.

    Now when you make changes to the database they will be saved as expected.

    If you want to know more about why this works, see the following post:
    http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=140988&SiteID=1

    Hope this helps,
    Steve Hoag
    Visual Basic Express


     



  • learning_to_code

    Magic Hat -

    Perhaps you missed an earlier step in the tutorial. If all of the earlier steps were followed, setting the CopyToOutputDirectory property to CopyIfNewer should allow you to see the updates.

    Steve Hoag

  • sample project "addresses" database