Note that there are some explanatory texts on larger screens.

plurals
  1. POWindows Form not getting updates from my database?
    text
    copied!<p>Ive only recently starting fiddling with Visual Basic Express and Sql Databases. </p> <p>Ive managed to get a database up and running, and can query information from it. I have even created a form that can add a new entry to the table im using.</p> <p>The first form has a ComboBox that list the PlayerNames in my table. Form2 allows you to add a new name to the table, but anything I add isnt immediately updated in Form1. I have to relaunch the program to see the new entries. Even then, these new entries dont seem to be permanent as they eventually dissappear.</p> <p>The code I have for Form1:</p> <pre><code>Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim db = New PlayerTestDataContextDataContext() Dim PlayerList = From List In db.Players Select List.PlayerName For Each PName In PlayerList cbPList.Items.Add(PName) Next End Sub Private Sub btnCreate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCreate.Click frmNewPlayer.Show() End Sub </code></pre> <p>End Class</p> <p>The code for Form2:</p> <pre><code> Private Sub btnCPlayer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCPlayer.Click Dim db = New PlayerTestDataContextDataContext() If txtNewPlayer.Text = "" Then lbWarning.Text = "Please enter a name!" Else Dim Plyr As New Player With { .PlayerName = txtNewPlayer.Text} db.Players.InsertOnSubmit(Plyr) db.SubmitChanges() Me.Close() End If End Sub </code></pre> <p>Not sure what is going wrong here...any help is appreciated. If I have overlooked an obvious answer around here forgive me, Im not sure what I need to be looking for.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload