GrogHeads Forum

Game Forge => DIY => Topic started by: OJsDad on August 03, 2015, 05:59:06 PM

Title: VB and Databse Help
Post by: OJsDad on August 03, 2015, 05:59:06 PM
I know a couple of you do some programming.  I'm playing around with Visual Studio 2013, more specifically VB 2013.  I created an Access DB and added it to my VB project.  I then drag one of the tables over to a form.  All of the code seems to create correctly.  I then run the code, add some data into the datagrid click the save button.  However, nothing ever writes to the DB.

Any ideas. 

Here is the code.

Quote
Public Class UtilitiesMenu

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles btnCloseUtilities.Click
        Me.Close()
    End Sub

    Private Sub NationsBindingNavigatorSaveItem_Click(sender As Object, e As EventArgs) Handles NationsBindingNavigatorSaveItem.Click
        Me.Validate()
        Me.NationsBindingSource.EndEdit()
        Me.TableAdapterManager.UpdateAll(Me.OneNationDataSet)

    End Sub

    Private Sub UtilitiesMenu_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'OneNationDataSet.Nations' table. You can move, or remove it, as needed.
        Me.NationsTableAdapter.Fill(Me.OneNationDataSet.Nations)

    End Sub

    Private Sub NationsBindingNavigator_RefreshItems(sender As Object, e As EventArgs) Handles NationsBindingNavigator.RefreshItems

    End Sub

End Class
Title: Re: VB and Databse Help
Post by: GJK on August 04, 2015, 07:15:47 AM
Throwing some lawn darts up into the air...

Can you write a simple script that appends/edits/deletes records from the db?  If you can't append, is it a permissions r/w/x issue?

Can you manually add a record and then query it from vb?  If not, are you sure that you're connecting to the db?

So my shot in the dark is read/write permissions and/or database connectivity.
Title: Re: VB and Databse Help
Post by: OJsDad on August 04, 2015, 08:21:56 AM
Thanks for the ideas GJK.  I did find the answer late last night.


Quote
The database used here is in the project folder and with each run of the app the database is copied fresh to the Bin\Debug folder. This means if you add a record, stop the app and run again only two rows show as we overwrote the database. To prevent this select the database in Solution Explorer, select Copy to output folder and use Copy If newer.

https://code.msdn.microsoft.com/vstudio/Adding-new-records-into-bff5eaaf