Main Menu

VB and Databse Help

Started by OJsDad, August 03, 2015, 05:59:06 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

OJsDad

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
'Here at NASA we all pee the same color.'  Al Harrison from the movie Hidden Figures.

GJK

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.
Clip your freaking corners!
----------------------
Blood Bowl on VASSAL - Ask me about it! http://garykrockover.com/BB/
----------------------
"Fat, drunk, and stupid is no way to go through life, son."

-Dean Vernon Wormer

OJsDad

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
'Here at NASA we all pee the same color.'  Al Harrison from the movie Hidden Figures.