Author Topic: VB and Databse Help  (Read 762 times)

0 Members and 1 Guest are viewing this topic.

Offline OJsDad

  • Landsknecht
  • *******
  • Posts: 4593
  • Fighting for Oppressed Individualism
VB and Databse Help
« on: August 03, 2015, 04: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
Truman: "The Buck Stop Here"

Obama: "The Blame Goes There"

"The wargamer in me really wats to see a US armored brigade with proper support mix it up with the Ruskis."  Starfury

"ACK! You're right there!?!? Ouch that first 20 minutes hurt.... a lot...."  Barthhart playing PBEM Flashpoint Red Storm

Southern Nights - Glen Campbell        https://youtu.be/zgCveCj7a5U


Offline GJK

  • Condottieri
  • ******
  • Posts: 2333
  • Posts: -4234
    • www.the-proving-grounds.com
Re: VB and Databse Help
« Reply #1 on: August 04, 2015, 06: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.
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

Offline OJsDad

  • Landsknecht
  • *******
  • Posts: 4593
  • Fighting for Oppressed Individualism
Re: VB and Databse Help
« Reply #2 on: August 04, 2015, 07: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
Truman: "The Buck Stop Here"

Obama: "The Blame Goes There"

"The wargamer in me really wats to see a US armored brigade with proper support mix it up with the Ruskis."  Starfury

"ACK! You're right there!?!? Ouch that first 20 minutes hurt.... a lot...."  Barthhart playing PBEM Flashpoint Red Storm

Southern Nights - Glen Campbell        https://youtu.be/zgCveCj7a5U